forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflexible.cpp
42 lines (32 loc) · 836 Bytes
/
flexible.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int w, p;
cin >> w >> p;
vector<int> walls;
walls.push_back(0);
for(int i = 0; i < p; i++) {
int temp;
cin >> temp;
walls.push_back(temp);
}
walls.push_back(w);
vector<int> possible;
// i is number of sections you're using
for(int i = 1; i < p+2; i++) {
// j is starting section number
for(int j = 0; j < p + 2 - i; j++) {
possible.push_back(walls[j+i] - walls[j]);
}
}
sort(possible.begin(), possible.end());
vector<int>::iterator it;
it = unique(possible.begin(), possible.end());
possible.resize(distance(possible.begin(), it));
for(auto i : possible) {
cout << i << " ";
}
cout << endl;
}