Problem:
Score : 300 points

Problem Statement

Given is a sequence of integers A_1, A_2, ..., A_N.
If its elements are pairwise distinct, print YES; otherwise, print NO.

Constraints

2 ≤ N ≤ 200000

1 ≤ A_i ≤ 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

If the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.

Sample Input 1

5
2 6 1 4 5

Sample Output 1

YES

The elements are pairwise distinct.

Sample Input 2

6
4 1 3 1 6 2

Sample Output 2

NO

The second and fourth elements are identical.

Sample Input 3

2
10000000 10000000

Sample Output 3

NO

Solution in C (GCC 9.2.1) (judge verdict: Accepted)

#include<stdio.h>
#include <stdlib.h>

const int N = 1e5 + 7;

void adjust(long long ara[], int l, int r, int mid) {
    int first = mid - l + 1;
    int second = r - mid;
    long long ara1[first];
    long long ara2[second];
    int pos1 = 0, pos2 = 0, pos = l;

    for(int i = 0 ; i < first ; ++i) {
        ara1[i] = ara[i + l];
    }
    for(int i = 0 ; i < second ; ++i) {
        ara2[i] = ara[i + mid + 1];
    }
    for( ; pos1 < first && pos2 < second ;) {
        if(ara1[pos1] < ara2[pos2]) {
            ara[pos] = ara1[pos1];
            pos1++;
        }
        else {
            ara[pos] = ara2[pos2];
            pos2++;
        }
        pos++;
    }
    for( ; pos1 < first ; ) {
        ara[pos] = ara1[pos1];
        pos++;
        pos1++;
    }
    for( ; pos2 < second ; ) {
        ara[pos] = ara2[pos2];
        pos++;
        pos2++;
    }
}

void mergesort(long long ara[], int l, int r) {
    if(l < r) {
        int mid = (l + (r - l) / 2);
        mergesort(ara, l, mid);
        mergesort(ara, mid + 1, r);
        adjust(ara, l, r, mid);
    }
}

long long Max(long long x, long long y) {
    if(x > y) return x;
    else return y;
}

int main() {
    int n;
    scanf("%d",&n);
    long long *ara = (long long*)malloc(sizeof(long long) * n);
    int i = 0;
    for(i = 0 ; i < n ; ++i) {
        scanf("%lld",&ara[i]);
    }
    mergesort(ara, 0, n - 1);
    int can = 1;
    for(int i = 1 ; i < n ; ++i) {
        if(ara[i] == ara[i - 1]) {
            can = 0;
            break;
        }
    }
    if(can) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }
    return 0;
}