Sunday, March 26, 2017

Uri 2290 - Apaixornados Numbers

#include <bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    long long ar[100010];
    int n;
    while(cin  >> n and n != 0){
        memset(ar,0,sizeof ar);
            int t = 0;
        for(int i = 0;i < n ; i++) cin >> ar[i];

        sort(ar,ar+n);
        for(int i= 0 ; i < n and t < 2 ;){
             if(ar[i] == ar[i+1] and i < n-1){
                i += 2;
             }else{
                 cout << ar[i];
                 cout << ((t == 1) ?  "\n" : " ") ;
                 i++;
                 t++;
             }
        }
    }
    return 0;
}

No comments: