From c1b13da17b2d20bdb9392f0e390df771772f0020 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Fri, 29 May 2020 17:37:43 +0200 Subject: chore: order in coding contest folder --- I_anno/Programmazione_2/coding_contest/gita.cpp | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 I_anno/Programmazione_2/coding_contest/gita.cpp (limited to 'I_anno/Programmazione_2/coding_contest/gita.cpp') diff --git a/I_anno/Programmazione_2/coding_contest/gita.cpp b/I_anno/Programmazione_2/coding_contest/gita.cpp new file mode 100644 index 0000000..cbb4910 --- /dev/null +++ b/I_anno/Programmazione_2/coding_contest/gita.cpp @@ -0,0 +1,46 @@ +#include +#include +#include +#include + +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> 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> 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; +} -- cgit v1.2.3-18-g5258