# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
670142 | 2022-12-08T07:43:34 Z | mychecksedad | Bootfall (IZhO17_bootfall) | C++17 | 1 ms | 340 KB |
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define pb push_back const int N = 510, M = 500; int n, a[N], S = 0; bitset<N*N/2> dp[N]; void solve(){ cin >> n; bool ok = 1; for(int i = 1; i <= n; ++i){ cin >> a[i]; S += a[i]; if(a[i] % 2 != a[1] % 2){ ok = 0; } } if(!ok || S % 2){ cout << 0; return; } for(int i = 0; i <= n; ++i){ dp[i][0] = 1; for(int l = 1; l <= n; ++l){ if(i == l) continue; for(int j = M - a[l]; j >= 0; --j){ dp[i][j + a[l]] = dp[i][j + a[l]] | (dp[i][j] << a[l]); } } } vector<int> possible; for(int x = 2 - (a[1] % 2); x <= M * M; x += 2){ ok = 1; a[0] = x; for(int i = 0; i <= n; ++i){ int req = (S + x - a[i]) >> 1, req1 = ((S + x - a[i]) >> 1) - x; bool state1 = (req < N*N/2 && dp[i][req]); bool state2 = (req1 >= 0 && dp[i][req1]); if(!state2){ ok = 0; break; } } if(ok){ possible.pb(x); } } cout << possible.size() << '\n'; for(int p: possible) cout << p << ' '; } int main(){ cin.tie(0); ios::sync_with_stdio(0); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Incorrect | 1 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Incorrect | 1 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Incorrect | 1 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Incorrect | 1 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Incorrect | 1 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Incorrect | 1 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |