Submission #1359985
Source Code Expand
//in the name of allah #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int , int> ii; const int MAXN = 1e5+10; int a[MAXN] , n; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i=0 ; i<n ; i++) cin >> a[i]; int mn = *min_element(a , a+n) , mx = *max_element(a , a+n); if(mx-mn > 1){ cout << "No\n"; return 0; } if(mx == mn){ if(a[0] * 2 > n && a[0] != n-1) cout << "No\n"; else cout << "Yes\n"; return 0; } int t=0 , all=0; for(int i=0 ; i<n ; i++) if(a[i] == mn) t ++; for(int i=0 ; i<n ; i++){ if(a[i] == mx) all = a[i]; } if(all <= t){ cout << "No\n"; return 0; } if((n-t) < (all-t)*2){ cout << "No\n"; return 0; } cout << "Yes\n"; } //.
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Hats |
User | AmSen |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 806 Byte |
Status | AC |
Exec Time | 9 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 | 7 ms | 640 KB |
1_03.txt | AC | 9 ms | 640 KB |
1_04.txt | AC | 9 ms | 640 KB |
1_05.txt | AC | 9 ms | 640 KB |
1_06.txt | AC | 9 ms | 640 KB |
1_07.txt | AC | 9 ms | 640 KB |
1_08.txt | AC | 7 ms | 640 KB |
1_09.txt | AC | 9 ms | 640 KB |
1_10.txt | AC | 7 ms | 640 KB |
1_11.txt | AC | 9 ms | 640 KB |
1_12.txt | AC | 9 ms | 640 KB |
1_13.txt | AC | 9 ms | 640 KB |
1_14.txt | AC | 9 ms | 640 KB |
1_15.txt | AC | 1 ms | 256 KB |
1_16.txt | AC | 1 ms | 256 KB |
1_17.txt | AC | 9 ms | 640 KB |