Submission #2147003


Source Code Expand

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1LL<<60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main(){
  int n;
  cin >> n;
  int a[n];
  REP(i, n) cin >> a[i];
  sort(a, a+n);
  if(a[n-1] - a[0] > 1){
    cout << "No" << endl;
    return 0;
  }
  int M = 0, N;
  N = a[n-1];
  while(a[M] == (N-1)) M++;
  if(M <= (N-1) && (2*N-M) <= n) cout << "Yes" << endl;
  else if(M == 0 && N == (n-1)) cout << "Yes" << endl;
  else cout << "No" << endl; 
	return 0;
}

Submission Info

Submission Time
Task B - Colorful Hats
User EctoPlasma
Language C++14 (GCC 5.4.1)
Score 700
Code Size 893 Byte
Status AC
Exec Time 39 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 20 ms 640 KB
1_03.txt AC 37 ms 640 KB
1_04.txt AC 38 ms 640 KB
1_05.txt AC 37 ms 640 KB
1_06.txt AC 38 ms 640 KB
1_07.txt AC 38 ms 640 KB
1_08.txt AC 20 ms 640 KB
1_09.txt AC 38 ms 640 KB
1_10.txt AC 20 ms 640 KB
1_11.txt AC 38 ms 640 KB
1_12.txt AC 37 ms 640 KB
1_13.txt AC 38 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 39 ms 640 KB