Codeforces Round #436 (Div. 2) Fair Game

/*
输入一堆数,如果是两个数并且个数相同就输出yes和这两个数
否则输出no
*/
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int num[maxn] = {0};
int a[maxn] = {0};
const int inf =0x3f3f3f3f;
int main()
{
    int n;
    int sum = 0;
    int flag1 = -inf, flag2 = -inf;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        num[a[i]]++;
    }
    for(int i = 1; i <= 100; i++)
    {
        if(num[i])
        {
            sum++;
            if(flag1 == -inf)
                flag1 = i;
            else if(flag2 == -inf)
                flag2 = i;
        }
    }
    if(sum == 2)
    {
        if(num[flag1] == num[flag2])
        {
            cout << "YES\n";
            cout << flag1 << ' ' << flag2 << endl;
        }
        else
            cout << "NO\n";
    }
    else
        cout << "NO\n";
    return 0;

}

 

posted @ 2017-09-26 20:26  Kearon  阅读(156)  评论(0编辑  收藏  举报