Submission #1360824
Source Code Expand
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }
int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
#define REP(i,a,b) for(int (i) = (a);i < (b);(i)++)
#define rep(i,n) REP(i,0,n)
#define PER(i,a,b) for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n) PER(i,n,0)
#define each(i,n) for(auto &i : n)
#define clr(a) memset((a), 0 ,sizeof(a))
#define mclr(a) memset((a), -1 ,sizeof(a))
#define all(a) (a).begin(),(a).end()
#define dump(val) cerr << #val " = " << val << endl;
#define dum(val) cerr << #val " = " << val;
#define FILL(a,v) fill(a,a+sizeof(a)/sizeof(*a),v)
const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e9;
// vector<int> stairs(int n){
// vector<int> a(n);
// rep(i, n) a[]
// }
signed main() {
int n;
cin >> n;
vector<int> a(n);
rep(i,n){
cin >> a[i];
}
sort(all(a));
int ma = a.back();
int mi = a.front();
map<int, int> mp;
each(i, a) mp[i]++;
if(mp.size() == 1 && a[0] == n-1){
cout << "Yes" << endl;return 0;
}
if(mp.size() >= 3 || mp[ma] < 2){
cout << "No" << endl;return 0;
}
if(ma - mi != 1){
cout << "No" << endl;return 0;
}
int mi_k = mp[mi]-1;
int ma_k = mp[ma]/2;
if(mi_k + 1 > mi){
cout << "No" << endl; return 0;
}
if(mi_k + ma_k >= mi){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Colorful Hats |
User |
omu |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1948 Byte |
Status |
WA |
Exec Time |
64 ms |
Memory |
7296 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 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 |
3 ms |
384 KB |
0_04.txt |
WA |
1 ms |
256 KB |
0_05.txt |
AC |
1 ms |
256 KB |
1_00.txt |
AC |
1 ms |
256 KB |
1_01.txt |
WA |
1 ms |
256 KB |
1_02.txt |
WA |
18 ms |
1024 KB |
1_03.txt |
AC |
31 ms |
1024 KB |
1_04.txt |
WA |
31 ms |
1024 KB |
1_05.txt |
AC |
31 ms |
1024 KB |
1_06.txt |
AC |
30 ms |
1024 KB |
1_07.txt |
AC |
31 ms |
1024 KB |
1_08.txt |
AC |
18 ms |
1024 KB |
1_09.txt |
AC |
31 ms |
1024 KB |
1_10.txt |
AC |
18 ms |
1024 KB |
1_11.txt |
AC |
31 ms |
1024 KB |
1_12.txt |
AC |
31 ms |
1024 KB |
1_13.txt |
AC |
30 ms |
1024 KB |
1_14.txt |
AC |
31 ms |
1152 KB |
1_15.txt |
AC |
1 ms |
256 KB |
1_16.txt |
AC |
1 ms |
256 KB |
1_17.txt |
AC |
64 ms |
7296 KB |