Submission #1359990


Source Code Expand

#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
int ans;
int a[100005];

void nope() {
	cout << "No" << endl;
	exit(0);
}

void yep() {
	cout << "Yes" << endl;
	exit(0);
}

int main() {
	//freopen("x.in", "r", stdin);
	
	cin >> n;
	F0(i, n) {
		cin >> a[i];
	}
	int n1 = *min_element(a, a + n);
	int n2 = *max_element(a, a + n);
	if (n2 - n1 > 1) nope();

	int c1 = count(a, a + n, n1);
	int c2 = count(a, a + n, n2);

	if (n1 == n2) {
		if (n1 == n - 1) yep();
		if (2 * n1 <= n) yep();
		nope();
	}

	if (c1 + c2 / 2 >= n2 && c2 > 1 && c1 < n2) yep();
	nope();

	return 0;
}

Submission Info

Submission Time
Task B - Colorful Hats
User USA
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1131 Byte
Status AC
Exec Time 38 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 6
AC × 24
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 640 KB
1_03.txt AC 37 ms 640 KB
1_04.txt AC 37 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 19 ms 640 KB
1_09.txt AC 37 ms 640 KB
1_10.txt AC 19 ms 640 KB
1_11.txt AC 37 ms 640 KB
1_12.txt AC 38 ms 640 KB
1_13.txt AC 37 ms 640 KB
1_14.txt AC 37 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