From f279107065146a4940f5e73602a1c3c09e58b31d Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 18 Oct 2020 18:56:43 +0200 Subject: chore: name of first year folder --- .../Programmazione_2/coding_contest/scheletri.cpp | 56 ---------------------- 1 file changed, 56 deletions(-) delete mode 100644 I_anno/Programmazione_2/coding_contest/scheletri.cpp (limited to 'I_anno/Programmazione_2/coding_contest/scheletri.cpp') diff --git a/I_anno/Programmazione_2/coding_contest/scheletri.cpp b/I_anno/Programmazione_2/coding_contest/scheletri.cpp deleted file mode 100644 index 2389d25..0000000 --- a/I_anno/Programmazione_2/coding_contest/scheletri.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include -#include -#include - -using namespace std; - -int find_i(int index, vector cms) { - for(int i = index; i < cms.size(); ++i) { - if(cms.at(i) != 0) - return i; - } - - return 0; -} - -int find_j(int index, vector cms) { - for(int j = index; j < cms.size()-1; ++j) { - if(cms.at(j+1) == 0) - return j+1; - } - - return cms.size(); -} - -int main() { - ifstream in("input.txt"); - ofstream out("output.txt"); - - short N; - for(int __c = 0; __c < 100; ++__c) { - in >> N; - vector cms; - int el; - for(short i = 0; i < N; ++i) { - in >> el; - cms.push_back(el); - } - - int counter{}; - int i{}, j{}; - while(count_if(begin(cms), end(cms), [](int num) { return num == 0; } ) != cms.size() ) { - i = find_i(i, cms); - j = find_j(i, cms); - for(int ii = i; ii < j; ++ii) { - --cms[ii]; - } - ++counter; - } - out << counter << endl; - } - - out.close(); - in.close(); - return 0; -} -- cgit v1.2.3-18-g5258