Submission #1453608
Source Code Expand
#include<bits/stdc++.h> using namespace std; long long N; vector<long long> a; set<long long> memo; bool check(long long N){ //cout << "N = " << N << endl; long long nnum = 0; long long nonenum = 0; for(long long i = 0; i < a.size(); i++){ if(a[i] == N-1){ nonenum++; }else if(a[i] == N){ nnum++; }else{ exit(1); } } //cout << "n - 1 = " << nonenum << " nnum = " << nnum << endl; if(nnum == 1){ return false; } long long mini; long long maxi; if(nnum > 1){ mini = nonenum + 1; maxi = nonenum + nnum/2; }else{ mini = nonenum; maxi = nonenum + nnum/2; } return mini <= N && N <= maxi; } int main(){ cin >> N; for(long long i = 0; i < N; i++){ long long tmp; cin >> tmp; a.push_back(tmp); memo.insert(tmp); } sort(a.begin(), a.end()); if(memo.size() > 2){ cout << "No" << endl; return 0; } if(memo.size() == 1){ if(check(a[0]) || check(a[0] + 1)){ cout << "Yes" << endl; return 0; }else{ cout << "No" << endl; return 0; } }else{ if(check(a[a.size() - 1])){ cout << "Yes" << endl; return 0; }else{ cout << "No" << endl; return 0; } } }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Hats |
User | motomuman |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1210 Byte |
Status | RE |
Exec Time | 51 ms |
Memory | 5748 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 | 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 | 19 ms | 1400 KB |
1_03.txt | AC | 31 ms | 1400 KB |
1_04.txt | AC | 32 ms | 1400 KB |
1_05.txt | AC | 32 ms | 1400 KB |
1_06.txt | AC | 32 ms | 1400 KB |
1_07.txt | AC | 33 ms | 1400 KB |
1_08.txt | AC | 19 ms | 1400 KB |
1_09.txt | AC | 31 ms | 1400 KB |
1_10.txt | AC | 19 ms | 1400 KB |
1_11.txt | AC | 32 ms | 1400 KB |
1_12.txt | AC | 31 ms | 1400 KB |
1_13.txt | AC | 31 ms | 1400 KB |
1_14.txt | AC | 31 ms | 1400 KB |
1_15.txt | RE | 1 ms | 256 KB |
1_16.txt | RE | 1 ms | 256 KB |
1_17.txt | AC | 51 ms | 5748 KB |