Submission #1386728
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b) for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
const int oo = 0x3f3f3f3f;
const int maxn = 100000 + 10;
template<typename T> T read() {
T n(0), f(1);
char ch = getchar();
for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48;
return n * f;
}
int n;
int a[maxn];
int main() {
#ifdef Wearry
freopen("data.txt", "r", stdin);
freopen("ans.txt", "w", stdout);
#endif
scanf("%d", &n);
REP(i, 0, n) scanf("%d", a + i);
sort(a, a + n);
if(a[n-1] - a[0] > 1) {
return puts("No"), 0;
}
if(a[n-1] - a[0] == 0) {
return puts((a[0] == n-1 || a[0] <= n/2) ? "Yes" : "No"), 0;
}
int col = a[0], gro = 0;
for(int i = 1; i < n; i++) {
if(a[i] == a[0])
-- col;
else ++ gro;
}
puts((col > 0 && col <= gro/2) ? "Yes" : "No");
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Colorful Hats |
User |
Wearry |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
1405 Byte |
Status |
AC |
Exec Time |
12 ms |
Memory |
640 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:37:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:38:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i, 0, n) 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 |
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 |
10 ms |
640 KB |
1_03.txt |
AC |
12 ms |
640 KB |
1_04.txt |
AC |
12 ms |
640 KB |
1_05.txt |
AC |
12 ms |
640 KB |
1_06.txt |
AC |
12 ms |
640 KB |
1_07.txt |
AC |
12 ms |
640 KB |
1_08.txt |
AC |
10 ms |
640 KB |
1_09.txt |
AC |
12 ms |
640 KB |
1_10.txt |
AC |
10 ms |
640 KB |
1_11.txt |
AC |
12 ms |
640 KB |
1_12.txt |
AC |
12 ms |
640 KB |
1_13.txt |
AC |
12 ms |
640 KB |
1_14.txt |
AC |
12 ms |
640 KB |
1_15.txt |
AC |
1 ms |
256 KB |
1_16.txt |
AC |
1 ms |
256 KB |
1_17.txt |
AC |
12 ms |
640 KB |