Submission #3047749
Source Code Expand
#include <bits/stdc++.h>
#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()
typedef long long ll;
using namespace std;
const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp[ohara],cmpp,m,h,w,x,y,sum=0,pos,k;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};
//-------------------------↓↓↓↓↓↓------------------------
int main(void){
cin.tie(0);
ios::sync_with_stdio(false);
cin>>n>>k;
ll ma=0;
map<ll,ll> mp;
rep(i,n){
cin>>a;
cmp[a]++;
ma=max(ma,a);
}
sort(cmp,cmp+ma+1);
rep(i,ma+1){
if(cmp[i]>0)cnt++;
}
//Cout(cnt);
cnt-=k;
if(cnt>0){
rep(i,ma+1){
if(cmp[i]==0)continue;
ans+=cmp[i];
cnt--;
if(cnt==0)break;
}
}
Cout(ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Not so Diverse |
User |
asdf1 |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1822 Byte |
Status |
AC |
Exec Time |
22 ms |
Memory |
1792 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample1.txt, sample2.txt, sample3.txt |
All |
sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name |
Status |
Exec Time |
Memory |
1.txt |
AC |
1 ms |
256 KB |
10.txt |
AC |
21 ms |
1792 KB |
11.txt |
AC |
21 ms |
1792 KB |
12.txt |
AC |
22 ms |
1792 KB |
13.txt |
AC |
20 ms |
1664 KB |
2.txt |
AC |
1 ms |
256 KB |
3.txt |
AC |
21 ms |
1792 KB |
4.txt |
AC |
22 ms |
1792 KB |
5.txt |
AC |
21 ms |
1792 KB |
6.txt |
AC |
19 ms |
1664 KB |
7.txt |
AC |
17 ms |
1024 KB |
8.txt |
AC |
18 ms |
1024 KB |
9.txt |
AC |
22 ms |
1792 KB |
sample1.txt |
AC |
1 ms |
256 KB |
sample2.txt |
AC |
1 ms |
256 KB |
sample3.txt |
AC |
1 ms |
256 KB |