Submission #1773188


Source Code Expand

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,a[233333];
bool ok(int g)
{
	for(int i=1;i<=n;++i)
		if(a[i]==g||a[i]==g-1);else return 0;
	int sg=0;
	for(int i=1;i<=n;++i)
		if(a[i]==g-1) ++sg;
	if(sg>g) return 0;
	int tt=n-sg;
	if(tt&&sg==g) return 0;
	if(tt==1) return 0;
	int tw=g-sg;
	if(tw<=tt/2) return 1;
	return 0;
}
int main()
{
	scanf("%d",&n); int m=0;
	for(int i=1;i<=n;++i)
		scanf("%d",a+i),m=max(m,a[i]);
	if(ok(m)||ok(m+1)) puts("Yes");
	else puts("No");
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:50:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n); int m=0;
                ^
./Main.cpp:52:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",a+i),m=max(m,a[i]);
                                ^

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 9 ms 640 KB
1_03.txt AC 11 ms 640 KB
1_04.txt AC 11 ms 640 KB
1_05.txt AC 11 ms 640 KB
1_06.txt AC 11 ms 640 KB
1_07.txt AC 11 ms 640 KB
1_08.txt AC 9 ms 640 KB
1_09.txt AC 11 ms 640 KB
1_10.txt AC 9 ms 640 KB
1_11.txt AC 11 ms 640 KB
1_12.txt AC 11 ms 640 KB
1_13.txt AC 11 ms 640 KB
1_14.txt AC 11 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