# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
566206 | RealSnake | Bootfall (IZhO17_bootfall) | C++14 | 1090 ms | 324 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long
#define mod 1000000007
ofstream fout(".out");
ifstream fin(".in");
signed main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
int arr[n + 1];
int sum = 0;
for(int i = 0; i < n; i++) {
cin >> arr[i];
sum += arr[i];
}
if(sum % 2) {
cout << 0;
return 0;
}
vector<int> ans;
for(int i = 1; i <= 2400; i++) {
arr[n] = i;
bool b = 1;
for(int j = 0; j <= n; j++) {
if(i > sum || arr[n] % 2 != arr[j] % 2) {
b = 0;
break;
}
sum += arr[n];
sum -= arr[j];
swap(arr[j], arr[n]);
int x;
for(int o = 0; o < (1 << n); o++) {
x = 0;
for(int k = 0; k < n; k++) {
if(o & (1 << k))
x += arr[k];
}
if(x == sum / 2)
break;
}
if(x != sum / 2)
b = 0;
sum += arr[n];
sum -= arr[j];
swap(arr[j], arr[n]);
if(!b)
break;
}
if(b)
ans.push_back(i);
}
cout << ans.size() << "\n";
for(int i : ans)
cout << i << " ";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |