Submission #3765734
Source Code Expand
#include<map> #include<set> #include<bitset> #include<cstdio> #include<iostream> #include<algorithm> #include<vector> #include<queue> #include<string> #include<chrono> #include<stack> #include<fstream> #include<list> #define REP(i,x,y) for(ll i=x;i<=y;i++) #define SIZE(a) ll(a.size()) #define vll vector<ll> #define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m #define BIT(n) (ll(1)<<n) #define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) #define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1 #define SORT(a,n) sort(a+1,a+n+1) #define SORT_O(a,n,order) sort(a+1,a+n+1,order) #define PER(i,y,x) for(ll i=y;i>=x;i--) typedef long long ll; using namespace std; struct point { long long name; long long dist; bool operator<(const point& rhs) const { return dist > rhs.dist; } }; ll const MAX = 200005; ll a[MAX]; int main() { ll n; cin >> n; REP(i, 1, n) { cin >> a[i]; } SORT(a, n); if (a[n] - a[1] >= 2) { cout << "No" << endl; return 0; } ll unq = 0; if (a[n] == a[1] && a[1] == n - 1) { cout << "Yes" << endl; return 0; } REP(i, 1, n) { if (a[n] != a[i]) { unq++; } else { break; } } ll col = a[n] - unq; ll num = n - unq; if (col <= 0) { cout << "No" << endl; } else if (num/col >= 2) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Hats |
User | nejineji |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1395 Byte |
Status | AC |
Exec Time | 30 ms |
Memory | 1024 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 | 17 ms | 1024 KB |
1_03.txt | AC | 30 ms | 1024 KB |
1_04.txt | AC | 30 ms | 1024 KB |
1_05.txt | AC | 30 ms | 1024 KB |
1_06.txt | AC | 30 ms | 1024 KB |
1_07.txt | AC | 30 ms | 1024 KB |
1_08.txt | AC | 18 ms | 1024 KB |
1_09.txt | AC | 30 ms | 1024 KB |
1_10.txt | AC | 17 ms | 1024 KB |
1_11.txt | AC | 30 ms | 1024 KB |
1_12.txt | AC | 30 ms | 1024 KB |
1_13.txt | AC | 30 ms | 1024 KB |
1_14.txt | AC | 30 ms | 1024 KB |
1_15.txt | AC | 1 ms | 256 KB |
1_16.txt | AC | 1 ms | 256 KB |
1_17.txt | AC | 30 ms | 1024 KB |