# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
640384 | 2022-09-14T13:44:15 Z | Kanimet0 | Kpart (eJOI21_kpart) | C++17 | 1543 ms | 812 KB |
#include <cstdio> #include <math.h> const int maxv = 1e5; int n, cnt; int A[maxv + 1], pref[maxv + 1], ans[maxv + 1]; short dp[maxv + 1]; void solve() { scanf("%d", &n); for(short i = 1; i <= n; i++) { scanf("%d", &A[i]); ans[i] = true; pref[i] = pref[i - 1] + A[i]; } dp[0] = maxv + 1; for(int j = 1; j <= maxv; j++) dp[j] = 0; int s = -1; for(short i = 1; i <= n; i++) { for(int j = maxv; j > A[i]; --j) dp[j] = std::max(dp[j], dp[j - A[i]]); dp[A[i]] = i; for(short k = 1; k <= i; k++) { s = (pref[i] - pref[k-1]); if((s & 1) || (dp[s / 2] < k)) ans[i - k + 1] = false; } } cnt = 0; for(short i = 1; i <= n; i++) if(ans[i]) cnt++; printf("%d", cnt); for(short i = 1; i <= n; i++) if(ans[i]) printf(" %d", i); printf("\n"); } int main() { int T; scanf("%d", &T); while(T--) solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 92 ms | 500 KB | Output is correct |
2 | Correct | 182 ms | 488 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 339 ms | 500 KB | Output is correct |
2 | Correct | 593 ms | 520 KB | Output is correct |
3 | Correct | 593 ms | 648 KB | Output is correct |
4 | Correct | 832 ms | 528 KB | Output is correct |
5 | Correct | 1258 ms | 676 KB | Output is correct |
6 | Correct | 1543 ms | 584 KB | Output is correct |
7 | Correct | 1387 ms | 812 KB | Output is correct |