# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
530738 | 2022-02-26T15:39:22 Z | Killer2501 | Bootfall (IZhO17_bootfall) | C++14 | 1 ms | 356 KB |
#include <bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define pll pair<ll, ll> #define pii pair<int, int> #define fi first #define se second using namespace std; const int N = 5e2+5; const int M = 250; const int mod = 1e9+7; const ll base = 75; const int inf = 1e9; int n, t, b[N*N], d[N], lab[N], c[N], a[N]; int ans, tong; ll dp[N*N]; ll m, k; pii p[N], start, finish; vector<int> gx[N], gy[N]; vector<pii> vi; string s[N]; void sol() { cin >> n; dp[0] = 1; for(int i = 1; i <= n; i ++) { cin >> a[i]; for(int j = tong; j >= 0; j --)dp[j+a[i]] += dp[j]; tong += a[i]; } for(int i = 1; i <= n; i ++) { for(int j = a[i]; j <= tong; j ++)dp[j] -= dp[j-a[i]]; tong -= a[i]; for(int j = (tong&1); j <= tong; j += 2) if(dp[(tong+j)>>1])++b[j]; for(int j = tong; j >= 0; j --)dp[j+a[i]] += dp[j]; tong += a[i]; } for(int i = 0; i < N*N; i ++)if(b[i] == n)++ans; cout << ans << '\n'; for(int i = 0; i < N*N; i ++)if(b[i] == n)cout << i <<" "; } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); #define task "test" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test = 1; //cin >> test; while(test -- > 0)sol(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 356 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 356 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 356 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 356 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 356 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 356 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |