2175: GJJ的日常之再游戏
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 819 Solved: 167
Submit Status Web Board
Description
GJJ和WJJ又开始了游戏,然而由于WJJ太强了,所以GJJ只好靠计谋取胜,而正因为WJJ太强,所以用过一次的计谋便无效了。
GJJ和WJJ一共玩了N场游戏,如果GJJ想要获胜,必须得赢的场数比Wjj多。
问:GJJ能否获胜?
Input
多实例,到文件尾结束
每个样例第一行一个N(1<=N<=50000),表示GJJ每场使用的计谋的数量;
第二行是N个数x,表示计谋的编号(0<=x<=1000000000)。
Output
对于每组样例,如果GJJ获胜输出"Yes";否则输出"No"。
Sample Input
5
1 2 3 4 5
5
1 2 2 2 1
Sample Output
Yes
No
这个题不知道为什么用set会超时,只能用暴力解决了。
#include <iostream>
#include<algorithm>
#include <set>
#include<stdio.h>
using namespace std;
int n;
int s[50010];
int main()
{
int a;
while(~scanf("%d",&n))
{
if(n==0)
break;
for(int i=0;i<n;i++)
{
scanf("%d",&s[i]);
}
sort(s,s+n);
int t=1;
for(int i=1;i<n;i++)
{
if(s[i]!=s[i-1])
t++;
}
int vv=n-t;
if(vv<t)
{
printf("Yes\n");
}
else
printf("No\n");
}
return 0;
}
#include<algorithm>
#include <set>
#include<stdio.h>
using namespace std;
int n;
int s[50010];
int main()
{
int a;
while(~scanf("%d",&n))
{
if(n==0)
break;
for(int i=0;i<n;i++)
{
scanf("%d",&s[i]);
}
sort(s,s+n);
int t=1;
for(int i=1;i<n;i++)
{
if(s[i]!=s[i-1])
t++;
}
int vv=n-t;
if(vv<t)
{
printf("Yes\n");
}
else
printf("No\n");
}
return 0;
}