Submission #1986029
Source Code Expand
#include<bits/stdc++.h> #define int long long #define fi first #define se second #define PB push_back using namespace std; typedef pair<int, int> P1; typedef pair<int, pair<int, int> > P2; static const int INF = 1ll<<60; static const int dx[] = { 1, -1, 0, 0, }; static const int dy[] = { 0, 0, 1, -1 }; static const int mod = 1000000007; int N,K; int a[200005]; int kind; int flag[200005]; int v[200005]; int ans; signed main(){ cin>>N>>K; for(int i=0;i<N;++i)v[i]=INF; for(int i=0;i<N;++i){ cin>>a[i]; a[i]--; if(!flag[a[i]]){ kind++; v[a[i]]=0; } flag[a[i]]=1; v[a[i]]++; } if(kind<=K){ cout<<0<<endl; return 0; } sort(v,v+N); for(int i=0;;++i){ if(kind==K)break; ans+=v[i]; kind--; } cout<<ans<<endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Not so Diverse |
User | koutarou |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 908 Byte |
Status | AC |
Exec Time | 65 ms |
Memory | 4992 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 | 2 ms | 2304 KB |
10.txt | AC | 63 ms | 4480 KB |
11.txt | AC | 63 ms | 4736 KB |
12.txt | AC | 65 ms | 4992 KB |
13.txt | AC | 56 ms | 4736 KB |
2.txt | AC | 1 ms | 2304 KB |
3.txt | AC | 62 ms | 4608 KB |
4.txt | AC | 63 ms | 4864 KB |
5.txt | AC | 62 ms | 4864 KB |
6.txt | AC | 54 ms | 4608 KB |
7.txt | AC | 57 ms | 4096 KB |
8.txt | AC | 57 ms | 4480 KB |
9.txt | AC | 63 ms | 4864 KB |
sample1.txt | AC | 1 ms | 2304 KB |
sample2.txt | AC | 1 ms | 2304 KB |
sample3.txt | AC | 1 ms | 2304 KB |