码迷,mamicode.com
首页 > 其他好文 > 详细

CodeForces - 864A Fair Game

时间:2017-09-30 13:38:02      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:否则   fine   ace   print   turn   signed   efi   codeforce   mes   

题意:如果一个序列中只有两种数,且这两种数的数量相同,则输出YES,并输出这两种数,否则输出NO。

#include<bits/stdc++.h>
#define Min(a, b) ((a < b) ? a : b)
#define Max(a, b) ((a < b) ? b : a)
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 100 + 10;
const int MAXT = 500 + 10;
using namespace std;
int a[MAXN];
int b[MAXN];
int main(){
    int n, x;
    scanf("%d", &n);
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        scanf("%d", &x);
        if(!a[x]){
            b[++cnt] = x;
        }
        ++a[x];
    }
    if(cnt == 2 && a[b[1]] == a[b[2]]){
        printf("YES\n%d %d\n", b[1], b[2]);
    }
    else{
        printf("NO\n");
    }
    return 0;
}

  

CodeForces - 864A Fair Game

标签:否则   fine   ace   print   turn   signed   efi   codeforce   mes   

原文地址:http://www.cnblogs.com/tyty-Somnuspoppy/p/7614425.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!