Submission #1606487
Source Code Expand
#include <bits/stdc++.h> using namespace std; int n, val, x, ap1, ap2, i; int main() { // freopen("input", "r", stdin); cin.sync_with_stdio(false); cin >> n >> val; ap1 = 1; for(i=2; i<=n; ++i) { cin >> x; if(x == val) ++ap1; else if(!ap2) { if(x == val-1) ap2 = ap1, ap1 = 1, --val; else if(x == val+1) ap2 = 1; else { cout << "No\n"; return 0; } } else if(x == val+1) ++ap2; else { cout << "No\n"; return 0; } } if(!ap2) { if(n/2 >= val || val == n-1) cout << "Yes\n"; else cout << "No\n"; } else { if(ap2 >= 2 && ap1 + ap2/2 >= val+1 && ap1 + 1 <= val + 1) cout << "Yes\n"; else cout << "No\n"; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Hats |
User | Alexa2001 |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1072 Byte |
Status | AC |
Exec Time | 9 ms |
Memory | 256 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 | 7 ms | 256 KB |
1_03.txt | AC | 9 ms | 256 KB |
1_04.txt | AC | 9 ms | 256 KB |
1_05.txt | AC | 9 ms | 256 KB |
1_06.txt | AC | 9 ms | 256 KB |
1_07.txt | AC | 9 ms | 256 KB |
1_08.txt | AC | 7 ms | 256 KB |
1_09.txt | AC | 9 ms | 256 KB |
1_10.txt | AC | 7 ms | 256 KB |
1_11.txt | AC | 9 ms | 256 KB |
1_12.txt | AC | 9 ms | 256 KB |
1_13.txt | AC | 9 ms | 256 KB |
1_14.txt | AC | 9 ms | 256 KB |
1_15.txt | AC | 1 ms | 256 KB |
1_16.txt | AC | 1 ms | 256 KB |
1_17.txt | AC | 1 ms | 256 KB |