-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTanyaAndToys.cpp
More file actions
41 lines (32 loc) · 747 Bytes
/
Copy pathTanyaAndToys.cpp
File metadata and controls
41 lines (32 loc) · 747 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 <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n, m;
int main() {
scanf("%d %d", &n, &m);
vector<int> isChecked(n);
vector<int> result;
for(int i = 0; i < n; i++) {
scanf("%d", &isChecked[i]);
}
int index = 1;
int checkIndex = 0;
sort(isChecked.begin(), isChecked.end());
while( m >= index) {
if(isChecked[checkIndex] == index) {
checkIndex++;
} else {
m -= index;
result.push_back(index);
}
index++;
}
printf("%d\n", result.size());
for(int i = 0, len = result.size(); i < len; i++) {
printf("%d ", result[i]);
}
printf("\n");
return 0;
}