Cod sursa(job #2922284)

Utilizator francescom_481francesco martinut francescom_481 Data 7 septembrie 2022 19:30:57
Problema Cele mai apropiate puncte din plan Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.75 kb
#include <bits/stdc++.h>

using namespace std ;
/*
ifstream fin("pinex.in");
ofstream fout("pinex.out");
#define cin fin
#define cout fout
*/
#define N 100004
int n, m, k, ok, a[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    for(int i = 1 ; i <= m ; i++)
    {
        cin >> a[i];
    }
    sort(a+1,a+m+1);
    for(int i = 1 ; i < m ; i++)
    {
        k = 0;
        while(a[i]+1 == a[i+1])
        {
            k++;
            i++;
        }
        if(k != 0)
        {
            if(k >= 2)
            {
                ok = 1;
            }
            i--;
        }
    }
    if(a[m] == n  ||  a[1] == 1)ok = 1;
    if(ok == 1)cout << "NO";
    else cout << "YES";
    return 0;
}