Submission #1361742
Source Code Expand
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;
const LL mod = 1e9 + 7;
template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
os<<"("<<t.first<<", "<<t.second<<")";
return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
return os;
}
const int MAXN = 1e5 + 100;
int arr[MAXN];
int main() {
ios_base::sync_with_stdio(false);
int n;
cin >> n;
int minim = 1e9, maxim = 0;
for(int i = 1; i <= n; i++) {
cin >> arr[i];
minim = min(minim, arr[i]);
maxim = max(maxim, arr[i]);
}
bool ok = true;
if(maxim - minim == 1) {
int rhs = 0;
for(int i = 1; i <= n; i++) {
if(maxim == arr[i]) {
rhs++;
}
}
int cx = n - rhs;
int beta = minim - cx + 1;
if(2*beta <= rhs && 2*beta > 0) {
ok = true;
} else {
ok = false;
}
} else if(maxim == minim) {
if(2*maxim <= n || n - 1 == maxim) ok = true;
else ok = false;
} else {
ok = false;
}
if(ok) cout << "Yes\n";
else cout << "No\n";
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Colorful Hats |
User |
bk2dcradle |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
1823 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 |