Submission #2831935
Source Code Expand
#include "bits/stdc++.h" using namespace std; #define MOD 1000000007 #define INF 1LL<<50 #define fst first #define sec second #define pb push_back #define int long long #define ALL(obj) (obj).begin(), (obj).end() #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define RFOR(i,a,b) for(int i = (b-1);i>=a;i--) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) RFOR(i,0,n) #define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define debug(x) cout << #x << " = " << (x) << endl; typedef long long ll; typedef pair<ll,ll> P; signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; map<int,int>mp; int a; REP(_,n){ cin >> a; if(a > n-1){ cout << "No" << endl; return 0; } mp[a]++; } if(mp.size() == 1){ if(a <= n/2 || a == n-1) cout << "Yes" << endl; else cout << "No" << endl; return 0; } auto itr = mp.begin(); a = itr->fst; int num = itr->sec; itr++; if(mp.size() > 2 || itr->fst != a+1){ cout << "No" << endl; return 0; } if(num <= a && a+1 <= num + itr->sec/2){ cout << "Yes" << endl; } else cout << "No" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Hats |
User | cinnamoroll |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1317 Byte |
Status | AC |
Exec Time | 43 ms |
Memory | 6528 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 | 6 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 | 6 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 | 43 ms | 6528 KB |