summaryrefslogtreecommitdiff
path: root/I_anno/Programmazione_2/ladri.cpp
diff options
context:
space:
mode:
authorSanto Cariotti <dcariotti24@gmail.com>2020-05-29 17:37:43 +0200
committerSanto Cariotti <dcariotti24@gmail.com>2020-05-29 17:37:43 +0200
commitc1b13da17b2d20bdb9392f0e390df771772f0020 (patch)
tree20f266a590a4bb36738355f54fd48f4229b58b05 /I_anno/Programmazione_2/ladri.cpp
parentbc8b5b446a6a2d37bae82e7ad20e31e1439a2f0b (diff)
chore: order in coding contest folder
Diffstat (limited to 'I_anno/Programmazione_2/ladri.cpp')
-rw-r--r--I_anno/Programmazione_2/ladri.cpp53
1 files changed, 0 insertions, 53 deletions
diff --git a/I_anno/Programmazione_2/ladri.cpp b/I_anno/Programmazione_2/ladri.cpp
deleted file mode 100644
index 04e8e65..0000000
--- a/I_anno/Programmazione_2/ladri.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#include<iostream>
-#include<fstream>
-#include<vector>
-
-using namespace std;
-
-int main() {
- ifstream in("input.txt");
- ofstream out("output.txt");
-
- for(short _ = 0; _ < 100; ++_) {
- int N, K, M;
- in >> N >> K >> M;
- int* path = new int[N+1];
- int i;
- for(i = 0; i < N; ++i)
- in >> path[i];
-
- path[i] = M;
- int start = 0;
- vector<int> values;
- /* 1 31 33 38 62 69 93 97 98 99 */
- /* x x x x x x
- * K = 30
- */
- for(int i = 0; i < N+1; ++i) {
- if(path[i] - start > K) {
- for(int j = i-1; j >= 0; --j) {
- if(path[i] - path[j] <= K) {
- values.push_back(path[j]);
- start = path[j];
- i = j;
- break;
- }
- }
- }
- }
-
- // Stampa la path corretta per debug
- for(auto const& i: values)
- cout << i << ' ';
-
- cout << endl;
- out << values.size() << endl;
- delete[] path;
- }
-
-
- out.close();
- in.close();
-
- return 0;
-}