# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
537455 |
2022-03-15T06:23:57 Z |
joelau |
Kpart (eJOI21_kpart) |
C++14 |
|
2000 ms |
1228 KB |
#include <bits/stdc++.h>
using namespace std;
int T,N,A[1005], sum[1005], dp[2][100005];
bitset<1005> bs;
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> T;
while (T--) {
cin >> N;
sum[0] = 0;
for (int i = 1; i <= N; ++i) {
cin >> A[i];
sum[i] = sum[i-1] + A[i];
}
bs.reset();
for (int i = 1; i <= N; ++i) bs[i] = 1;
memset(dp[1],-1,sizeof(dp[1]));
dp[1][0] = 0;
for (int i = 1; i <= N; ++i) {
memset(dp[0],-1,sizeof(dp[0]));
dp[0][0] = dp[0][A[i]] = i;
for (int j = 0; j + A[i] <= sum[i] && j + A[i] <= sum[N]/2; ++j) dp[0][j] = max(dp[0][j],dp[1][j]), dp[0][j+A[i]] = max(dp[0][j+A[i]],dp[1][j]);
for (int j = 1; j <= i; ++j) {
int total = sum[i] - sum[j-1];
if (total % 2 == 1 || dp[0][total/2] < j) bs[i-j+1] = 0;
}
swap(dp[0],dp[1]);
}
cout << bs.count();
for (int i = 1; i <= N; ++i) if (bs[i]) cout << ' ' << i;
cout << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
980 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
1108 KB |
Output is correct |
2 |
Correct |
198 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
504 ms |
1108 KB |
Output is correct |
2 |
Correct |
713 ms |
1108 KB |
Output is correct |
3 |
Correct |
890 ms |
1108 KB |
Output is correct |
4 |
Correct |
1128 ms |
1224 KB |
Output is correct |
5 |
Correct |
1855 ms |
1228 KB |
Output is correct |
6 |
Execution timed out |
2088 ms |
1188 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |