# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
786916 | 2023-07-18T14:41:26 Z | Bula | Kpart (eJOI21_kpart) | C++14 | 1917 ms | 391396 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define int ll const ll mod=1e9+7; int dp[1001][50001],pref[1001]; main(){ int tt; cin>>tt; while(tt--){ int n; cin>>n; vector<int> v(n+1); int s=0; for(int i=1;i<=n;i++){ cin>>v[i]; pref[i]=0; s+=v[i]; } for(int i=1;i<=n;i++){ for(int j=1;j<=s/2;j++){ dp[i][j]=0; } } for(int i=1;i<=n;i++){ pref[i]=pref[i-1]+v[i]; for(int j=s/2;j>=1;j--){ dp[i][j]=dp[i-1][j]; if(j>v[i]) dp[i][j]=max(dp[i][j],dp[i-1][j-v[i]]); if(j==v[i]) dp[i][j]=i; } } vector<int> k; for(int i=2;i<=n;i++){ bool ok = true; for(int j=i;j<=n;j++){ int sum=pref[j]-pref[j-i]; if(sum%2==1 || dp[j][sum/2]<=j-i){ ok = false; break; } } if(ok == true) k.pb(i); } cout<<k.size()<<" "; for(int i=0;i<k.size();i++){ cout<<k[i]<<" "; } cout<<endl; // for(int i=1;i<=n;i++){ // for(int j=1;j<=s;j++){ // cout<<dp[i][j]<<" "; // } // cout<<endl; // } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 724 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2516 KB | Output is correct |
2 | Correct | 27 ms | 7104 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 104 ms | 27332 KB | Output is correct |
2 | Correct | 289 ms | 61368 KB | Output is correct |
3 | Correct | 327 ms | 78156 KB | Output is correct |
4 | Correct | 591 ms | 130756 KB | Output is correct |
5 | Correct | 1384 ms | 320752 KB | Output is correct |
6 | Correct | 1917 ms | 385600 KB | Output is correct |
7 | Correct | 1703 ms | 391396 KB | Output is correct |