Submission #3018812
Source Code Expand
#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) ((a) & 1 == (b) & 1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;
const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;
int N,a;
prique<int> que;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
rep(i,N){
cin >> a;
que.push(a);
}
int l = que.top(),tmp,ans = 0;
while(!que.empty()){
int cnt = 0;
while(!que.empty() && (tmp = que.top()) == l){
++cnt;
que.pop();
}
ans += cnt < l ? cnt : (cnt - l);
l = tmp;
}
esc(ans);
}
Submission Info
Submission Time |
|
Task |
C - Good Sequence |
User |
jell |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1452 Byte |
Status |
AC |
Exec Time |
21 ms |
Memory |
892 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt |
All |
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt |
Case Name |
Status |
Exec Time |
Memory |
0_00.txt |
AC |
1 ms |
256 KB |
0_01.txt |
AC |
1 ms |
256 KB |
0_02.txt |
AC |
1 ms |
256 KB |
0_03.txt |
AC |
1 ms |
256 KB |
0_04.txt |
AC |
1 ms |
256 KB |
1_00.txt |
AC |
1 ms |
256 KB |
1_01.txt |
AC |
1 ms |
256 KB |
1_02.txt |
AC |
10 ms |
892 KB |
1_03.txt |
AC |
12 ms |
892 KB |
1_04.txt |
AC |
13 ms |
892 KB |
1_05.txt |
AC |
13 ms |
892 KB |
1_06.txt |
AC |
15 ms |
892 KB |
1_07.txt |
AC |
15 ms |
892 KB |
1_08.txt |
AC |
17 ms |
892 KB |
1_09.txt |
AC |
19 ms |
892 KB |
1_10.txt |
AC |
19 ms |
892 KB |
1_11.txt |
AC |
21 ms |
892 KB |
1_12.txt |
AC |
21 ms |
892 KB |