Skip to content

Making the code too short and Fast compile #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 32 additions & 40 deletions 2020/Div 3/661 Div 3/Programs/Remove Smallest.cpp
Original file line number Diff line number Diff line change
@@ -1,44 +1,36 @@
#include <iostream>
#include <vector>
#include <algorithm>

#define all(v) (v).begin(), (v).end()
#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;

void solve()
{
int no_of_elements;
cin >> no_of_elements;

vector <int> A(no_of_elements + 1);
for(int i = 1; i <= no_of_elements; i++)
{
cin >> A[i];
}

sort(all(A));

int possible = true;

for(int i = 2; i <= no_of_elements; i++)
{
if(A[i] - A[i - 1] > 1)
{
possible = false;
break;
}
}

cout << (possible ? "YES\n" : "NO\n");
}

int main()
{
int no_of_test_cases;
cin >> no_of_test_cases;

while(no_of_test_cases--)
solve();

return 0;
lli t,n,i,a,k;
cin>>t;
while(t--){
cin>>n;
k=0;
vector<lli>v;
for(i=0;i<n;i++){
cin>>a;
v.pb(a);
}
sort all(v);
for(i=1;i<n;i++){
a=v[i]-v[i-1];
if(a<=1)
k++;
}
if(k==n-1)
cout<<"YES\n";
else
cout<<"NO\n";
}
return 0;
}