blob: cbb4910a4d179ff0470500f75f535d52feffa4c0 (
plain)
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
|
#include<iostream>
#include<fstream>
#include<vector>
#include<map>
using namespace std;
int main() {
ifstream in("input.txt");
ofstream out("output.txt");
for(int c = 0; c < 100; ++c) {
int N, L;
in >> N >> L;
vector<pair<short, int>> students;
for(int i = 0; i < N; ++i) {
int num;
in >> num;
students.push_back({num, 0});
}
int index, val;
for(int i = 0; i < L; ++i) {
in >> index >> val;
students[index].second += val;
}
vector<pair<short, int>> errors;
short _j{};
for(auto const& i : students) {
if(i.second < i.first) {
errors.push_back({_j, i.first-i.second});
}
_j++;
}
out << errors.size() << ' ';
for(auto const& i : errors) {
out << i.first << ' ' << i.second << ' ';
}
out << endl;
}
out.close();
in.close();
return 0;
}
|