Submission #2411796
Source Code Expand
#include <cstdio> #include <cstring> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> using namespace std; int main() { int n, a[100001]; scanf("%d", &n); for(int i=0; i<n; i++){ scanf("%d", &a[i]); } sort(a, a+n); if(a[n-1]-a[0]>1){ printf("%s\n", "No"); }else if(a[n-1]-a[0]==1){ int k=0; for(int i=0; i<n; i++){ if(a[i]==a[0]) k++; } if(n-a[n-1]+1<=n-k && n-k<=2*(n-a[n-1])){ printf("%s\n", "Yes"); }else{ printf("%s\n", "No"); } }else{ if(2*a[0]<=n || a[0]==n-1){ printf("%s\n", "Yes"); }else{ printf("%s\n", "No"); } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Hats |
User | chocorusk |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 677 Byte |
Status | AC |
Exec Time | 11 ms |
Memory | 512 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:15:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:17:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &a[i]); ^
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 | 128 KB |
0_01.txt | AC | 1 ms | 128 KB |
0_02.txt | AC | 1 ms | 128 KB |
0_03.txt | AC | 1 ms | 128 KB |
0_04.txt | AC | 1 ms | 128 KB |
0_05.txt | AC | 1 ms | 128 KB |
1_00.txt | AC | 1 ms | 128 KB |
1_01.txt | AC | 1 ms | 128 KB |
1_02.txt | AC | 9 ms | 512 KB |
1_03.txt | AC | 11 ms | 512 KB |
1_04.txt | AC | 11 ms | 512 KB |
1_05.txt | AC | 11 ms | 512 KB |
1_06.txt | AC | 11 ms | 512 KB |
1_07.txt | AC | 11 ms | 512 KB |
1_08.txt | AC | 9 ms | 512 KB |
1_09.txt | AC | 11 ms | 512 KB |
1_10.txt | AC | 9 ms | 512 KB |
1_11.txt | AC | 11 ms | 512 KB |
1_12.txt | AC | 11 ms | 512 KB |
1_13.txt | AC | 11 ms | 512 KB |
1_14.txt | AC | 11 ms | 512 KB |
1_15.txt | AC | 1 ms | 128 KB |
1_16.txt | AC | 1 ms | 128 KB |
1_17.txt | AC | 11 ms | 512 KB |