Submission #1359983
Source Code Expand
#include <iostream> #include <set> #include <algorithm> #include <vector> #include <map> using namespace std; int n; int a[100000]; int main() { ios_base::sync_with_stdio(0); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); if (a[n - 1] - a[0] > 1) { cout << "No"; return 0; } int cnt1 = 0; for (int i = 0; i < n; i++) { if (a[i] == a[0]) cnt1++; } if (cnt1 == n) { if (a[0] * 2 <= n || a[0] == n - 1) { cout << "Yes"; } else { cout << "No"; } } else { int cnt2 = n - cnt1; int among2 = a[n - 1] - cnt1; if (among2 >= 1 && among2 * 2 <= cnt2) { cout << "Yes"; } else { cout << "No"; } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Hats |
User | Lightless |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 803 Byte |
Status | AC |
Exec Time | 10 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 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 | 8 ms | 640 KB |
1_03.txt | AC | 10 ms | 640 KB |
1_04.txt | AC | 10 ms | 640 KB |
1_05.txt | AC | 10 ms | 640 KB |
1_06.txt | AC | 10 ms | 640 KB |
1_07.txt | AC | 10 ms | 640 KB |
1_08.txt | AC | 8 ms | 640 KB |
1_09.txt | AC | 10 ms | 640 KB |
1_10.txt | AC | 8 ms | 640 KB |
1_11.txt | AC | 10 ms | 640 KB |
1_12.txt | AC | 10 ms | 640 KB |
1_13.txt | AC | 10 ms | 640 KB |
1_14.txt | AC | 10 ms | 640 KB |
1_15.txt | AC | 1 ms | 256 KB |
1_16.txt | AC | 1 ms | 256 KB |
1_17.txt | AC | 10 ms | 640 KB |