forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB_Petya_and_Staircases.cpp
45 lines (44 loc) · 1.14 KB
/
B_Petya_and_Staircases.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <bits/stdc++.h>
#define mod 1000000007
#define lli long long int
#define endl '\n'
#define deb(x) cout << #x << '=' << x << '\n'
#define deb2(x, y) cout << #x << '=' << x << ',' << #y << '=' << y << '\n'
#define deb3(x, y, z) cout << #x << '=' << x << ',' << #y << '=' << y << ',' << #z << '=' << z << '\n'
#define deb4(x, y, z, w) cout << #x << '=' << x << ',' << #y << '=' << y << ',' << #z << '=' << z << ',' << #w << '=' << w << '\n'
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, d;
cin >> n >> d;
if (d == 0)
{
cout << "YES";
return 0;
}
vector<int> v1(d);
for (int i = 0; i < d; i++)
cin >> v1[i];
sort(v1.begin(), v1.end());
if (v1[0] == 1 || v1[d - 1] == n)
cout << "NO";
else
{
bool ans = true;
for (int i = 1; i < d - 1; i++)
{
if ((v1[i + 1] - v1[i] == 1) && (v1[i] - v1[i - 1] == 1))
{
ans = false;
break;
}
}
if (ans)
cout << "YES";
else
cout << "NO";
}
return 0;
}