summaryrefslogtreecommitdiff
path: root/I_anno/Programmazione_2/coding_contest/scheletri.cpp
diff options
context:
space:
mode:
authorSanto Cariotti <dcariotti24@gmail.com>2020-10-18 18:56:43 +0200
committerSanto Cariotti <dcariotti24@gmail.com>2020-10-20 09:08:52 +0200
commitf279107065146a4940f5e73602a1c3c09e58b31d (patch)
treefd892749637a8b6c5c31ccb80bba04ade76ab87a /I_anno/Programmazione_2/coding_contest/scheletri.cpp
parent4e063e32250312c38d5646840719b62429362b21 (diff)
chore: name of first year folder
Diffstat (limited to 'I_anno/Programmazione_2/coding_contest/scheletri.cpp')
-rw-r--r--I_anno/Programmazione_2/coding_contest/scheletri.cpp56
1 files changed, 0 insertions, 56 deletions
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<iostream>
-#include<fstream>
-#include<vector>
-#include<algorithm>
-
-using namespace std;
-
-int find_i(int index, vector<int> cms) {
- for(int i = index; i < cms.size(); ++i) {
- if(cms.at(i) != 0)
- return i;
- }
-
- return 0;
-}
-
-int find_j(int index, vector<int> 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<int> 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;
-}