| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 168437 | Gurban | Bootfall (IZhO17_bootfall) | C++14 | 1077 ms | 3320 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 pb push_back
#define ss second
#define ff first
#define N 250009
#define inf 1000000009
#define ll long long
#define mid(a,b) (a+b)/2
using namespace std;
int n,a[509],sum,dp[N],s;
map <int,int> m;
vector <int> v;
const int mod = 1e9+7;
int main()
{
scanf("%d",&n);
for(int i = 1;i <= n;i++){
scanf("%d",&a[i]);
sum += a[i];
}
dp[0] = 1;
for(int i = 1;i <= n;i++)
for(int j = sum;j >= 0;j--)
dp[j + a[i]] += dp[j];
if(sum % 2 == 1 or dp[sum / 2] == 0)
return cout << 0,0;
for(int i = 1;i <= n;i++){
for(int j = a[i];j <= sum;j++)
dp[j] -= dp[j - a[i]];
for(int j = 1;j < sum;j++){
s = sum - a[i] + j;
if(s % 2 == 0 and s / 2 - j >= 0 and dp[s / 2 - j])
m[j]++;
}
for(int j = sum;j >= a[i];j--)
dp[j] += dp[j - a[i]];
}
for(auto i : m)
if(i.ss == n) v.pb(i.ff);
printf("%d\n",v.size());
for(auto i : v) printf("%d\n",i);
}
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... | ||||
