diff options
author | Santo Cariotti <dcariotti24@gmail.com> | 2020-10-18 18:56:43 +0200 |
---|---|---|
committer | Santo Cariotti <dcariotti24@gmail.com> | 2020-10-20 09:08:52 +0200 |
commit | f279107065146a4940f5e73602a1c3c09e58b31d (patch) | |
tree | fd892749637a8b6c5c31ccb80bba04ade76ab87a /1_anno/Programmazione_2/coding_contest/gita.cpp | |
parent | 4e063e32250312c38d5646840719b62429362b21 (diff) |
chore: name of first year folder
Diffstat (limited to '1_anno/Programmazione_2/coding_contest/gita.cpp')
-rw-r--r-- | 1_anno/Programmazione_2/coding_contest/gita.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/1_anno/Programmazione_2/coding_contest/gita.cpp b/1_anno/Programmazione_2/coding_contest/gita.cpp new file mode 100644 index 0000000..cbb4910 --- /dev/null +++ b/1_anno/Programmazione_2/coding_contest/gita.cpp @@ -0,0 +1,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; +} |