# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92739 | janchomath | Bootfall (IZhO17_bootfall) | C++14 | 1085 ms | 504 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>
#define ll int
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,a[20005],dp[20005],sum,s,oo,x;
vector<ll>anss,v;
bool check(ll k){
v.clear();
s = 0;
for(int i=1; i<=n; i++)if(i != k)v.pb(a[i]),s += a[i];
if(s % 2 == 1)return false;
for(int i=1; i<=s; i++)dp[i] = 0;
dp[0] = 1;
for(int i=0; i<v.size(); i++){
for(int j=s; j>=0; j--){
dp[j + v[i]] = max(dp[j],dp[j + v[i]]);
if(dp[j + v[i]] && j + v[i] == s/2){
return true;
}
}
}
return false;
}
int main(){
std::ios::sync_with_stdio(false);
cin >> n;
for(int i=1; i<=n; i++){
cin >> a[i];
sum += a[i];
}
n++;
for(x=1; x<=sum; x++){
a[n] = x;
oo = 0;
for(int i=1; i<=n; i++){
if(!check(i)){
oo = 1;
break;
}
}
if(!oo){
anss.pb(x);
}
}
cout << anss.size() << endl;
for(int i=0; i<anss.size(); i++)cout << anss[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... |