# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
786827 | 2023-07-18T13:19:08 Z | Bula | Kpart (eJOI21_kpart) | C++17 | 431 ms | 100472 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]; main(){ int tt; cin>>tt; while(tt--){ int n; cin>>n; vector<int> v(n+1),pref(n+1); int s=0; for(int i=1;i<=n;i++){ cin>>v[i]; s+=v[i]; } for(int i=1;i<=n;i++){ pref[i]=pref[i-1]+v[i]; } for(int i=1;i<=n;i++){ for(int j=1;j<=50000;j++){ dp[i][j]=0; } } for(int i=1;i<=n;i++){ dp[i][v[i]]=i; for(int j=1;j<=50000;j++){ if(dp[i-1][j]>0) dp[i][j]=max(dp[i][j],dp[i-1][j]); if(j-v[i]>=0 && dp[i-1][j-v[i]]>0) dp[i][j]=max(dp[i][j],dp[i][j-v[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){ ok = false; }else{ if(dp[j][sum/2]<=j-i) ok = false; } } 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 | Incorrect | 27 ms | 11988 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 118 ms | 26524 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 431 ms | 100472 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |