Submission #2525324
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v)) //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100002;
ll n,ans;
vector<ll> a;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;
FOR(i,0,n){
ll k;
cin>>k;
a.pb(k);
}
SORT(a);
FOR(i,0,n){
ll k=NUM(a,a[i]);
if(k-a[i]>=0)ans+=(k-a[i]);
else ans+=k;
i+=k;
i--;
}
pri(ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Good Sequence |
User |
kenta2997 |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1218 Byte |
Status |
AC |
Exec Time |
27 ms |
Memory |
1400 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 |
8 ms |
1400 KB |
1_03.txt |
AC |
11 ms |
1400 KB |
1_04.txt |
AC |
11 ms |
1400 KB |
1_05.txt |
AC |
11 ms |
1400 KB |
1_06.txt |
AC |
13 ms |
1400 KB |
1_07.txt |
AC |
11 ms |
1400 KB |
1_08.txt |
AC |
15 ms |
1400 KB |
1_09.txt |
AC |
19 ms |
1400 KB |
1_10.txt |
AC |
21 ms |
1400 KB |
1_11.txt |
AC |
25 ms |
1400 KB |
1_12.txt |
AC |
27 ms |
1400 KB |