# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
537444 |
2022-03-15T06:14:12 Z |
joelau |
Kpart (eJOI21_kpart) |
C++14 |
|
2000 ms |
1352 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] <= 100000; ++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 |
Correct |
81 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
247 ms |
1108 KB |
Output is correct |
2 |
Correct |
519 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
892 ms |
1108 KB |
Output is correct |
2 |
Correct |
1577 ms |
1352 KB |
Output is correct |
3 |
Correct |
1604 ms |
1256 KB |
Output is correct |
4 |
Execution timed out |
2097 ms |
1144 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |