-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproblem65.cpp
More file actions
41 lines (35 loc) · 826 Bytes
/
problem65.cpp
File metadata and controls
41 lines (35 loc) · 826 Bytes
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
#include <iostream>
#include <unordered_set>
#include <vector>
using namespace std;
class ScienceFairClubSplit {
public:
int n, k;
vector<int> themes;
void readInput() {
cin >> n >> k;
int theme;
for (int i = 0; i < n; ++i) {
cin >> theme;
themes.push_back(theme);
}
}
bool isPossibleSplit() {
unordered_set<int> uniqueThemes;
for (int t : themes) {
uniqueThemes.insert(t);
}
return uniqueThemes.size() >= k;
}
void printResult(bool possible) {
if (possible) cout << "YES" << endl;
else cout << "NO" << endl;
}
};
int main() {
ScienceFairClubSplit sfcs;
sfcs.readInput();
bool possible = sfcs.isPossibleSplit();
sfcs.printResult(possible);
return 0;
}