Submission #19461512


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,K;
int A[303030];
int C[303030];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>A[i];
		C[A[i]]++;
	}
	ll ret=0;
	int alive=K;
	FOR(i,N+1) {
		alive=min(alive,C[i]);
		ret+=alive;
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Submission Info

Submission Time
Task B - Mex Boxes
User kmjp
Language C++ (GCC 9.2.1)
Score 400
Code Size 1089 Byte
Status AC
Exec Time 37 ms
Memory 5964 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:20:8: warning: unused variable ‘j’ [-Wunused-variable]
   20 |  int i,j,k,l,r,x,y; string s;
      |        ^
./Main.cpp:20:10: warning: unused variable ‘k’ [-Wunused-variable]
   20 |  int i,j,k,l,r,x,y; string s;
      |          ^
./Main.cpp:20:12: warning: unused variable ‘l’ [-Wunused-variable]
   20 |  int i,j,k,l,r,x,y; string s;
      |            ^
./Main.cpp:20:14: warning: unused variable ‘r’ [-Wunused-variable]
   20 |  int i,j,k,l,r,x,y; string s;
      |              ^
./Main.cpp:20:16: warning: unused variable ‘x’ [-Wunused-variable]
   20 |  int i,j,k,l,r,x,y; string s;
      |                ^
./Main.cpp:20:18: warning: unused variable ‘y’ [-Wunused-variable]
   20 |  int i,j,k,l,r,x,y; string s;
      |                  ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
./Main.cpp:42:38: note: in expansion of macro ‘FOR’
   42 |  FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                      ^~~

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 25 ms 4788 KB
hand_02.txt AC 20 ms 4676 KB
hand_03.txt AC 27 ms 4828 KB
hand_04.txt AC 24 ms 4784 KB
hand_05.txt AC 29 ms 4640 KB
hand_06.txt AC 25 ms 4828 KB
hand_07.txt AC 28 ms 4760 KB
hand_08.txt AC 23 ms 5480 KB
hand_09.txt AC 26 ms 5032 KB
hand_10.txt AC 37 ms 5016 KB
hand_11.txt AC 31 ms 5024 KB
hand_12.txt AC 32 ms 5020 KB
hand_13.txt AC 33 ms 5852 KB
hand_14.txt AC 25 ms 5924 KB
hand_15.txt AC 36 ms 5964 KB
hand_16.txt AC 31 ms 5964 KB
random_01.txt AC 16 ms 4656 KB
random_02.txt AC 15 ms 4364 KB
random_03.txt AC 21 ms 5164 KB
random_04.txt AC 20 ms 4988 KB
random_05.txt AC 17 ms 4424 KB
random_06.txt AC 17 ms 4428 KB
random_07.txt AC 23 ms 5056 KB
random_08.txt AC 21 ms 4780 KB
random_09.txt AC 16 ms 4312 KB
random_10.txt AC 15 ms 4440 KB
random_11.txt AC 20 ms 4920 KB
random_12.txt AC 16 ms 4580 KB
random_13.txt AC 15 ms 4524 KB
random_14.txt AC 23 ms 5124 KB
random_15.txt AC 20 ms 5076 KB
random_16.txt AC 18 ms 4352 KB
random_17.txt AC 19 ms 5028 KB
random_18.txt AC 27 ms 4932 KB
random_19.txt AC 18 ms 4548 KB
random_20.txt AC 14 ms 4252 KB
random_21.txt AC 18 ms 4820 KB
random_22.txt AC 23 ms 4656 KB
random_23.txt AC 17 ms 4396 KB
random_24.txt AC 25 ms 5064 KB
random_25.txt AC 18 ms 4272 KB
random_26.txt AC 19 ms 3984 KB
random_27.txt AC 12 ms 3988 KB
random_28.txt AC 23 ms 5036 KB
random_29.txt AC 17 ms 4068 KB
random_30.txt AC 16 ms 3988 KB
random_31.txt AC 13 ms 3952 KB
random_32.txt AC 29 ms 5072 KB
random_33.txt AC 17 ms 4200 KB
random_34.txt AC 18 ms 4220 KB
random_35.txt AC 14 ms 4040 KB
random_36.txt AC 20 ms 4940 KB
sample_01.txt AC 2 ms 3652 KB
sample_02.txt AC 4 ms 3500 KB
sample_03.txt AC 3 ms 3592 KB