Codeforces Round #436 (Div. 2)
敲出一身冷汗。。。感觉自己宛如智障:(
codeforces 864 A. Fair Game【水】
题意:已知n为偶数,有n张卡片,每张卡片上都写有一个数,两个人每人选一个数,每人可以拿的卡片必须写有是自己选的数,问能否选择两个数使得两个人每人拿的卡片数一样多并且能拿光卡片。[就是看输入是不是只有两种数字]
//:第一遍我看成字符串包含有选的数字也能拿,,这样写着居然过了。。水题水题。。
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int N=101; 6 int n, a[N]; 7 int main() { 8 int i, k, x=0, y=0; 9 scanf("%d", &n); 10 for(i = 1; i <= n; ++i){ 11 scanf("%d", &k);a[k]++; 12 if(!x) x=k; else if(k!=x) y=k; 13 } 14 if(a[x]==a[y] && a[x]+a[y]==n){printf("YES\n%d %d\n", x, y);} 15 else puts("NO"); 16 return 0; 17 }