Codeforces 1399A. Remove Smallest Solution

 Solution in C++:

///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int t,f,i,n;
    cin>>t;
    while(t--)
    {
        f=0;
        cin>>n;
        int a[n];
        for(i=0; i<n; i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        for(i=1; i<n; i++)
        {
            if(a[i]-a[i-1]>1)
            {
                f=1;
                cout<<"NO"<<endl;
                break;
            }
        }
        if(f==0)
            cout<<"YES"<<endl;
    }
}

1 comment:

  1. Cool and that i have a dandy give: What To Expect When Renovating A House renovate my home

    ReplyDelete

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.