Saturday, 12 September 2015

UVA 12239 Bingo! (UVALive 4806, Regionals 2010 >> Latin America)

///     Raihan Ruhin
///     CSE, Jahangirnagar University.
///     Dhaka-Bangladesh.
///     id: raihanruhin (topcoder / codeforces / codechef / uva / uvalive / spoj), 3235 (lightoj)
///     mail: raihanruhin@ (yahoo / gmail / facebook)
///     blog: ruhinraihan.blogspot.com

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

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100010


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int tc, kk=1, n, b, arr[95];
    string s;
    char ch;
    while(cin>>n>>b && n)
    {
        set<int>st;
        for(int i=0;i<b;i++)
            cin>>arr[i];
        for(int i=0;i<b;i++)
            for(int j=i+1;j<b;j++)
                st.insert(abs(arr[i]-arr[j]));

        int cnt=1;
        vector<int>v;
        for(auto i: st)
            v.push_back(i);
        //for(int i=0;i<v.size();i++) cout<<v[i]<<" ";
        if(v.size()>=n && v[n-1]==n)
            cout<<"Y\n";
        else cout<<"N\n";
    }
return 0;
}

No comments:

Post a Comment