# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890164 | 2023-12-20T16:07:41 Z | kim | Kpart (eJOI21_kpart) | C++17 | 1433 ms | 1148 KB |
#include<bits/stdc++.h> using namespace std; using ll=long long; #define eb emplace_back const int MX=100000; int a[1005],qs[1005]; int dp[MX+5]; void solve(){ int n; cin>>n; for(int i=1;i<=n;++i){ cin>>a[i]; qs[i]=a[i]+qs[i-1]; } for(int i=0;i<=MX;++i) dp[i]=0; vector<bool> ok(n+5,1); for(int i=1;i<=n;++i){ for(int j=MX-a[i];j>=1;--j) if(dp[j]) dp[j+a[i]]=max(dp[j+a[i]],dp[j]); dp[a[i]]=i; for(int j=1,k=i;j<i;++j,--k){ if((qs[i]-qs[j-1])&1) ok[k]=0; else if(dp[qs[i]-qs[j-1]>>1]<j) ok[k]=0; } } vector<int> ans; for(int i=2;i<=n;++i){ if(ok[i]) ans.eb(i); } cout<<ans.size()<<" "; for(auto &e:ans) cout<<e<<" "; cout<<endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int Q(1); cin>>Q; while(Q--){ solve(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 600 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 78 ms | 860 KB | Output is correct |
2 | Correct | 139 ms | 860 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 301 ms | 860 KB | Output is correct |
2 | Correct | 504 ms | 864 KB | Output is correct |
3 | Correct | 530 ms | 876 KB | Output is correct |
4 | Correct | 722 ms | 860 KB | Output is correct |
5 | Correct | 1228 ms | 1148 KB | Output is correct |
6 | Correct | 1433 ms | 1100 KB | Output is correct |
7 | Correct | 1362 ms | 856 KB | Output is correct |