Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<map>
- #include<vector>
- #define long long long
- #define nln '\n'
- using namespace std;
- int main()
- {
- cin.tie(0)->sync_with_stdio(0);
- long n;
- cin >> n;
- map<long, long> tic;
- while (n--){
- long x;
- cin >> x;
- vector<long> sum;
- for (auto i : tic)
- sum.push_back(i.first+x);
- for (auto i : sum)
- tic[i] = 1;
- tic[x] = 1;
- }
- cout << tic.size() << nln;
- for (auto i : tic)
- cout << i.first << ' ';
- cout << nln;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment