Submission #1986121
Source Code Expand
#include <iostream> #include <cstdio> #include <cstring> using namespace std; int main() { int N, K; scanf("%d %d",&N,&K); int A[N]; for (int i=0; i<N; i++) { scanf("%d",&A[i]); } int cnt[N+1]; memset(cnt,0,sizeof(cnt)); for (int i=0; i<N; i++) { cnt[A[i]]++; } int type; int ans=0; while (true) { type=0; for (int i=1; i<=N; i++) { if (cnt[i]>0) { type++; } } if (type<=K) { break; } int min_n=1; int x; for (int i=1; i<=N; i++) { if (cnt[i]!=0) { min_n=min(cnt[i],min_n); x=i; } } cnt[x]--; ans++; if (cnt[x]==0) { type--; } } printf("%d\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Not so Diverse |
User | Tom2 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 758 Byte |
Status | WA |
Exec Time | 2103 ms |
Memory | 1792 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:8:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d",&N,&K); ^ ./Main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&A[i]); ^
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 1 ms | 256 KB |
10.txt | TLE | 2103 ms | 1792 KB |
11.txt | TLE | 2103 ms | 1792 KB |
12.txt | TLE | 2103 ms | 1792 KB |
13.txt | AC | 20 ms | 1664 KB |
2.txt | WA | 1 ms | 256 KB |
3.txt | TLE | 2103 ms | 1792 KB |
4.txt | TLE | 2103 ms | 1792 KB |
5.txt | TLE | 2103 ms | 1792 KB |
6.txt | AC | 20 ms | 1664 KB |
7.txt | AC | 20 ms | 1664 KB |
8.txt | AC | 21 ms | 1792 KB |
9.txt | TLE | 2103 ms | 1792 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |