# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
840924 |
2023-08-31T23:06:10 Z |
pera |
Kpart (eJOI21_kpart) |
C++17 |
|
909 ms |
916 KB |
#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int N = 2e5 + 1;
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int t = 1;cin >> t;
while(t --){
int n;cin >> n;
vector<int> a(n + 1) , p(n + 1) , ls(n + 1) , ans;
for(int i = 1;i <= n;i ++){
cin >> a[i];
p[i] = p[i - 1] + a[i];
ls[i] = 1;
}
int X = p[n] / 2;
vector<int> dp(X);
for(int i = 1;i <= n;i ++){
auto ndp = dp;
dp[a[i]] = i;
for(int j = X;j > a[i];j --){
dp[j] = max(dp[j] , ndp[j - a[i]]);
}
for(int k = 1;k <= i;k ++){
ls[i - k + 1] &= ((p[i] - p[k - 1]) % 2 == 0 && dp[(p[i] - p[k - 1]) / 2] >= k);
}
}
cout << accumulate(ls.begin() , ls.end() , 0) << endl;
for(int i = 1;i <= n;i ++){
if(ls[i] == 1) cout << i << " ";
}
cout << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
16 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
420 KB |
Output is correct |
2 |
Correct |
132 ms |
544 KB |
Output is correct |
3 |
Correct |
150 ms |
488 KB |
Output is correct |
4 |
Correct |
269 ms |
544 KB |
Output is correct |
5 |
Correct |
616 ms |
808 KB |
Output is correct |
6 |
Correct |
909 ms |
664 KB |
Output is correct |
7 |
Correct |
788 ms |
916 KB |
Output is correct |