1438B - Valerii Against Everyone - CodeForces Solution


constructive algorithms data structures greedy sortings *1000

Please click on ads to support us..

Python Code:

import sys


l = sys.stdin.readlines()
i = 0

t = int(l[i].replace('\n',''))
i=1
while True:
    n = int(l[i].replace('\n',''))
    i+=1
    b = [int(x) for x in l[i].replace('\n', '').split()]
    i+=1

    b.sort()
    aux = 1
    for j in range(1,len(b)):
        aux = b[j] - b[j-1]
        if aux == 0:
            print('YES')
            break
    if aux != 0:
        print('NO')
    if i == len(l):
        break
		   	    		 	 			 		 	  	   	

C++ Code:

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

#define FAST()                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define wTC()                         \
    int t;                            \
    cin >> t;                         \
    for (int i = 1; i <= t; i++)      \
    {                                 \
        cout << "Case " << i << ": "; \
        nasim();                      \
    }
#define TC()     \
    int t;       \
    cin >> t;    \
    while (t--)  \
    {            \
        nasim(); \
    }
#define nTC()    \
    int t = 1;   \
    while (t--)  \
    {            \
        nasim(); \
    }

#define endl "\n"
#define ll long long int
#define mod 1e9 + 7
#define all(x) x.begin(), x.end()
#define getunique(v)                                  \
    {                                                 \
        sort(v.begin(), v.end());                     \
        v.erase(unique(v.begin(), v.end()), v.end()); \
    }

void nasim()
{
    int n;
    cin>>n;
    set<int>s;
    for(int i=0;i<n;i++)
    {
       int a;
       cin>>a;
       s.insert(a);
    }
    if(s.size()==n)
    {
        cout<< "NO"<<endl;
    }
    else
    {
        cout<< "YES"<<endl;
    }
}

int main()
{
    FAST()
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    // nTC();

    TC();

    // wTC();
}


Comments

Submit
0 Comments
More Questions

405A - Gravity Flip
499B - Lecture
709A - Juicer
1358C - Celex Update
1466B - Last minute enhancements
450B - Jzzhu and Sequences
1582C - Grandma Capa Knits a Scarf
492A - Vanya and Cubes
217A - Ice Skating
270A - Fancy Fence
181A - Series of Crimes
1638A - Reverse
1654C - Alice and the Cake
369A - Valera and Plates
1626A - Equidistant Letters
977D - Divide by three multiply by two
1654B - Prefix Removals
1654A - Maximum Cake Tastiness
1649A - Game
139A - Petr and Book
1612A - Distance
520A - Pangram
124A - The number of positions
1041A - Heist
901A - Hashing Trees
1283A - Minutes Before the New Year
1654D - Potion Brewing Class
1107B - Digital root
25A - IQ test
785A - Anton and Polyhedrons