Click
Here to go back to the homepage.
Flexible Spaces Solution:
#include <bits/stdc++.h>
using namespace std;
int main(){
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
int room, partitions;
cin >> room >> partitions;
int breakpoint;
vector<int> breakpoints = {0};
bool possibilies[room + 1] = {};
for(int i = 0; i < partitions; i++){
cin >> breakpoint;
for(int j:breakpoints){
possibilies[breakpoint - j] = true;
}
breakpoints.push_back(breakpoint);
}
breakpoints.push_back(room);
for(int i:breakpoints){
possibilies[room - i] = true;
}
for(int i = 1; i <= room; i++){
if(possibilies[i]){
cout << i << " ";
}
}
return 0;
}