# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
539069 |
2022-03-18T10:55:38 Z |
ddy888 |
Kpart (eJOI21_kpart) |
C++17 |
|
2000 ms |
172260 KB |
// #undef _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
// #define fi first
// #define si second
// #define ar array
// typedef pair<int,int> pi;
// typedef tuple<int,int,int> ti;
// void debug_out() {cerr<<endl;}
// template <typename Head, typename... Tail>
// void debug_out(Head H, Tail... T) {cerr<<" "<<to_string(H);debug_out(T...);}
// #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
int T;
int N;
int main() {
fast;
cin >> T;
while (T--) {
cin >> N;
vector<int> A(N + 1), ps(N + 1);
for (int i = 1; i <= N; ++i) {
cin >> A[i];
ps[i] = ps[i - 1] + A[i];
}
vector<vector<int> > dp(N + 1, vector<int>(50100));
vector<int> cannot(N + 1);
for (int en = 1; en <= N; ++en) {
dp[en][0] = en;
if (A[en] <= 50000) dp[en][A[en]] = en;
for (int value = 1; value <= 50000; ++value) {
if (value >= A[en]) dp[en][value] = max(dp[en - 1][value - A[en]], dp[en - 1][value]);
else dp[en][value] = dp[en - 1][value];
}
for (int i = 1; i <= en; ++i) {
int sum = ps[en] - ps[i - 1];
if (sum % 2 != 0 || dp[en][sum / 2] < i) cannot[en - i + 1] = 1;
}
}
vector<int> ans;
for (int i = 1; i <= N; ++i) if (!cannot[i]) ans.pb(i);
cout << ans.size() << ' ';
for (auto i: ans) cout << i << ' ';
cout << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
6516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
154 ms |
13820 KB |
Output is correct |
2 |
Correct |
367 ms |
23652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
662 ms |
51028 KB |
Output is correct |
2 |
Correct |
1111 ms |
75796 KB |
Output is correct |
3 |
Correct |
1102 ms |
85724 KB |
Output is correct |
4 |
Correct |
1527 ms |
111292 KB |
Output is correct |
5 |
Execution timed out |
2101 ms |
172260 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |