Submission #1359989
Source Code Expand
#include<stdio.h> #include<assert.h> #include<vector> #include<string.h> #include<algorithm> #include<memory.h> #include<cmath> #include<string> #include<iostream> #include<set> #include<unordered_set> #include<map> #include<queue> #include<functional> #include<list> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double, double> pdd; typedef tuple<int,int,int> t3; const int MX = 1<<19; const int MM = 1000000007; int D[MX]; int main() { int N; scanf("%d", &N); int mn = 1e9, mx = 0; for(int i = 1; i <= N; i++){ scanf("%d", D+i); mn = min(mn, D[i]); mx = max(mx, D[i]); } if( mn == mx ){ if( mn > N/2 && mn != N-1 ) return !printf("No\n"); else printf("Yes\n"); } else if( mn + 1 == mx ){ int c = 0; for(int i = 1; i <= N; i++){ if( D[i] == mn ) c++; } if( N-c <= 1 ) printf("No\n"); else if( c+1 <= mx && mx <= c+(N-c)/2) printf("Yes\n"); else printf("No\n"); } else{ printf("No\n"); } }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Hats |
User | zigui |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1052 Byte |
Status | AC |
Exec Time | 10 ms |
Memory | 640 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:33:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.cpp:36:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", D+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 | 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 | 8 ms | 640 KB |
1_03.txt | AC | 10 ms | 640 KB |
1_04.txt | AC | 10 ms | 640 KB |
1_05.txt | AC | 10 ms | 640 KB |
1_06.txt | AC | 10 ms | 640 KB |
1_07.txt | AC | 10 ms | 640 KB |
1_08.txt | AC | 8 ms | 640 KB |
1_09.txt | AC | 10 ms | 640 KB |
1_10.txt | AC | 8 ms | 640 KB |
1_11.txt | AC | 10 ms | 640 KB |
1_12.txt | AC | 10 ms | 640 KB |
1_13.txt | AC | 10 ms | 640 KB |
1_14.txt | AC | 10 ms | 640 KB |
1_15.txt | AC | 1 ms | 256 KB |
1_16.txt | AC | 1 ms | 256 KB |
1_17.txt | AC | 10 ms | 640 KB |