Submission #19473795


Source Code Expand

#include<bits/stdc++.h>
#define N 300010
using namespace std;
int k,n;
int a[N],b[N];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),b[a[i]]++;
	long long sum=0;
	for(int i=0;i<=n;i++)
		if(b[i]<k)sum+=(long long)i*(k-b[i]),k=b[i];
	printf("%lld\n",sum);
	return 0;
}

Submission Info

Submission Time
Task B - Mex Boxes
User pengym
Language C++ (GCC 9.2.1)
Score 400
Code Size 310 Byte
Status AC
Exec Time 42 ms
Memory 6020 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:8:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    8 |  scanf("%d%d",&n,&k);
      |  ~~~~~^~~~~~~~~~~~~~
./Main.cpp:9:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    9 |  for(int i=1;i<=n;i++) scanf("%d",&a[i]),b[a[i]]++;
      |                        ~~~~~^~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 55
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 36 ms 4768 KiB
hand_02.txt AC 31 ms 4844 KiB
hand_03.txt AC 25 ms 4720 KiB
hand_04.txt AC 32 ms 4708 KiB
hand_05.txt AC 34 ms 4708 KiB
hand_06.txt AC 36 ms 4692 KiB
hand_07.txt AC 35 ms 4808 KiB
hand_08.txt AC 33 ms 5468 KiB
hand_09.txt AC 39 ms 5044 KiB
hand_10.txt AC 39 ms 4988 KiB
hand_11.txt AC 38 ms 5112 KiB
hand_12.txt AC 39 ms 5008 KiB
hand_13.txt AC 39 ms 5896 KiB
hand_14.txt AC 35 ms 5840 KiB
hand_15.txt AC 42 ms 5860 KiB
hand_16.txt AC 38 ms 6020 KiB
random_01.txt AC 19 ms 4644 KiB
random_02.txt AC 21 ms 4372 KiB
random_03.txt AC 30 ms 5048 KiB
random_04.txt AC 23 ms 4968 KiB
random_05.txt AC 22 ms 4404 KiB
random_06.txt AC 25 ms 4528 KiB
random_07.txt AC 29 ms 5036 KiB
random_08.txt AC 22 ms 4904 KiB
random_09.txt AC 16 ms 4440 KiB
random_10.txt AC 17 ms 4352 KiB
random_11.txt AC 29 ms 4844 KiB
random_12.txt AC 19 ms 4532 KiB
random_13.txt AC 21 ms 4452 KiB
random_14.txt AC 31 ms 5060 KiB
random_15.txt AC 28 ms 5032 KiB
random_16.txt AC 17 ms 4448 KiB
random_17.txt AC 29 ms 4904 KiB
random_18.txt AC 24 ms 5028 KiB
random_19.txt AC 17 ms 4640 KiB
random_20.txt AC 18 ms 4468 KiB
random_21.txt AC 21 ms 4856 KiB
random_22.txt AC 20 ms 4844 KiB
random_23.txt AC 21 ms 4400 KiB
random_24.txt AC 30 ms 5108 KiB
random_25.txt AC 23 ms 4376 KiB
random_26.txt AC 19 ms 4124 KiB
random_27.txt AC 17 ms 4120 KiB
random_28.txt AC 30 ms 4896 KiB
random_29.txt AC 20 ms 4092 KiB
random_30.txt AC 16 ms 4148 KiB
random_31.txt AC 18 ms 4076 KiB
random_32.txt AC 35 ms 4968 KiB
random_33.txt AC 19 ms 4280 KiB
random_34.txt AC 18 ms 4108 KiB
random_35.txt AC 18 ms 4028 KiB
random_36.txt AC 23 ms 4956 KiB
sample_01.txt AC 2 ms 3612 KiB
sample_02.txt AC 2 ms 3644 KiB
sample_03.txt AC 2 ms 3540 KiB