Submission #1858117


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int c[1000005];

int main()
{ios_base::sync_with_stdio(false);
int n,k;
cin>>n>>k;
rep(i,1,n)
{
	int x;
	cin>>x;
	c[x]++;
}
sort(c,c+1000005);
int cnt=0;
rep(i,0,1000004)
{
	if(c[i])cnt++;
}
int ans=0;
if(cnt<=k)
{
	ol("0");
	return 0;
}
int x=cnt-k;
rep(i,0,1000004)
{
	if(x)
	{
		if(c[i])
		{
			ans+=c[i];
			x--;
		}
	}
}
ol(ans);
return 0;
}

Submission Info

Submission Time
Task C - Not so Diverse
User abisheka
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1739 Byte
Status
Exec Time 36 ms
Memory 4224 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 300 / 300 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 18 ms 4224 KB
10.txt 35 ms 4224 KB
11.txt 35 ms 4224 KB
12.txt 36 ms 4224 KB
13.txt 33 ms 4224 KB
2.txt 18 ms 4224 KB
3.txt 35 ms 4224 KB
4.txt 35 ms 4224 KB
5.txt 35 ms 4224 KB
6.txt 33 ms 4224 KB
7.txt 32 ms 4224 KB
8.txt 32 ms 4224 KB
9.txt 36 ms 4224 KB
sample1.txt 18 ms 4224 KB
sample2.txt 17 ms 4224 KB
sample3.txt 18 ms 4224 KB