-
-
Notifications
You must be signed in to change notification settings - Fork 78
/
bingo.cpp
48 lines (35 loc) · 784 Bytes
/
bingo.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
46
47
48
// https://www.urionlinejudge.com.br/judge/en/problems/view/1136
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
bool isPossible(const set<int> s, int n) {
int i = 0;
if (n > *s.rbegin()) return false;
for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
if (*it != i) return false;
i++;
}
return true;
}
int main() {
int n, b, x;
while (cin >> n && cin >> b && n + b != 0) {
vector<int> v;
set<int> s;
for (int i = 0; i < b; i++) {
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
for (int i = v.size()-1; i >= 0; i--) {
for (int j = i; j >= 0; j--) {
s.insert(v[i] - v[j]);
}
}
if (isPossible(s, n)) cout << "Y" << endl;
else cout << "N" << endl;
}
return 0;
}