diff options
author | Santo Cariotti <dcariotti24@gmail.com> | 2020-03-20 22:50:15 +0100 |
---|---|---|
committer | Santo Cariotti <dcariotti24@gmail.com> | 2020-03-20 22:50:15 +0100 |
commit | ad38f2e1ea8a392eecd1de9509455a5309d28a58 (patch) | |
tree | 8f4106ca6a18a89060292b37f029c3b0a59c16b5 /I_anno/Programmazione_2 | |
parent | 17fe8d8ee1af621ba54c083a04f7d38e04e1c061 (diff) |
feat: coding contest 20/03/20
Diffstat (limited to 'I_anno/Programmazione_2')
-rw-r--r-- | I_anno/Programmazione_2/gita.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/I_anno/Programmazione_2/gita.cpp b/I_anno/Programmazione_2/gita.cpp new file mode 100644 index 0000000..cbb4910 --- /dev/null +++ b/I_anno/Programmazione_2/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; +} |