Submission #1604161


Source Code Expand

#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 100100;

int n, p[MAXN], cnt[MAXN];

int main() {
	scanf("%d",&n);
	REP(i, n) scanf("%d",&p[i]);
	REP(i, n) cnt[p[i]]++;

  int tot = 0;
  REP(i, MAXN) tot += (cnt[i] > 0);

  if (tot == 1) {
    (2 * p[0] > n && p[0] != n - 1) ? puts("No") : puts("Yes");
    return 0;
  }

  if (tot > 2) {
    puts("No");
    return 0;
  }

  sort(p, p + n);
  int a = p[0];
  int b = p[n - 1];

  if (!(a - cnt[a] + 1) || cnt[b] % (a - cnt[a] + 1)) puts("No");
  else puts("Yes");
	return 0;
}

Submission Info

Submission Time
Task B - Colorful Hats
User mkisic
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1187 Byte
Status WA
Exec Time 12 ms
Memory 1024 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:37:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:38:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  REP(i, n) scanf("%d",&p[i]);
                             ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 6
AC × 21
WA × 3
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 9 ms 640 KB
1_03.txt AC 10 ms 640 KB
1_04.txt AC 10 ms 640 KB
1_05.txt AC 11 ms 640 KB
1_06.txt AC 10 ms 640 KB
1_07.txt WA 12 ms 640 KB
1_08.txt WA 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 11 ms 640 KB
1_14.txt AC 12 ms 640 KB
1_15.txt WA 1 ms 256 KB
1_16.txt AC 1 ms 256 KB
1_17.txt AC 10 ms 1024 KB