Submission #1360822
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,true):false;} template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,true):false;} ll nextInt() { int x; cin >> x; return x; } const int MAX_N = 100000 + 10; int a[MAX_N]; int N; bool f(int N, int M) { if (N <= 0 || M <= 0) return false; if (M == 1) return true; if (M == N - 1) return true; if (N >= 2 * M) return true; else return false; } bool solve() { if (a[N-1] - a[0] >= 2) return false; if (a[0] == a[N-1]) { return f(N, a[0]); } else { int m = 0; REP(i, N) { if (a[0] == a[i]) m++; } return f(N-m, 1+a[0]-m); } } int main2() { N = nextInt(); REP(i, N) a[i] = nextInt(); sort(a, a + N); bool res = solve(); cout << (res ? "Yes":"No") << endl; return 0; } int main() { for (;!cin.eof();cin>>ws) main2(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Hats |
User | hs484 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1040 Byte |
Status | WA |
Exec Time | 38 ms |
Memory | 640 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 | WA | 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 | 20 ms | 640 KB |
1_03.txt | AC | 37 ms | 640 KB |
1_04.txt | AC | 38 ms | 640 KB |
1_05.txt | AC | 37 ms | 640 KB |
1_06.txt | AC | 37 ms | 640 KB |
1_07.txt | AC | 37 ms | 640 KB |
1_08.txt | AC | 20 ms | 640 KB |
1_09.txt | AC | 38 ms | 640 KB |
1_10.txt | AC | 20 ms | 640 KB |
1_11.txt | AC | 38 ms | 640 KB |
1_12.txt | AC | 37 ms | 640 KB |
1_13.txt | AC | 38 ms | 640 KB |
1_14.txt | WA | 38 ms | 640 KB |
1_15.txt | AC | 1 ms | 256 KB |
1_16.txt | AC | 1 ms | 256 KB |
1_17.txt | AC | 37 ms | 640 KB |