Submission #1360819
Source Code Expand
#include<bits/stdc++.h> using namespace std; int N, A[100000]; bool check(int A_0) { int kind1 = 0; for(int i = 0; i < N; i++) { if(A[i] == A_0) ++kind1; } int kind2 = N - kind1; if(A_0 < kind1 - 1 + (kind2 != 0)) return (false); int sz = A_0 + 1 - kind1; while(sz > 0 && kind2 > 1) { sz--; kind2 -= 2; } if(sz == 0) return (true); return (false); } int main() { cin >> N; for(int i = 0; i < N; i++) cin >> A[i]; sort(A, A + N); if(abs(A[0] != A[N - 1]) > 2) cout << "No" << endl; else if(check(A[0])) cout << "Yes" << endl; else if(count(A, A + N, A[0]) == N && check(A[0] - 1)) cout << "Yes" << endl; else cout << "No" << endl; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Hats |
User | ei13333 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 715 Byte |
Status | WA |
Exec Time | 38 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.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, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.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 |
0_05.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 | 20 ms | 640 KB |
1_03.txt | AC | 38 ms | 640 KB |
1_04.txt | AC | 38 ms | 640 KB |
1_05.txt | AC | 38 ms | 640 KB |
1_06.txt | AC | 37 ms | 640 KB |
1_07.txt | AC | 38 ms | 640 KB |
1_08.txt | AC | 20 ms | 640 KB |
1_09.txt | AC | 38 ms | 640 KB |
1_10.txt | AC | 20 ms | 640 KB |
1_11.txt | AC | 38 ms | 640 KB |
1_12.txt | AC | 38 ms | 640 KB |
1_13.txt | AC | 38 ms | 640 KB |
1_14.txt | AC | 38 ms | 640 KB |
1_15.txt | WA | 1 ms | 256 KB |
1_16.txt | AC | 1 ms | 256 KB |
1_17.txt | AC | 37 ms | 640 KB |