# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
537521 |
2022-03-15T07:38:08 Z |
zaneyu |
Kpart (eJOI21_kpart) |
C++14 |
|
1578 ms |
1008 KB |
/*input
2
7
7 3 5 1 3 3 5
6
1 2 3 5 8 3
*/
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define MNTO(x,y) x=min(x,y)
#define MXTO(x,y) x=max(x,y)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define ld long double
#define sz(x) (int)x.size()
#define pb push_back
const int maxn=1e3+5;
int pref[maxn],arr[maxn];
int dp[50005],ndp[50005];
bool wk[maxn];
void solve(){
int n;
cin>>n;
REP1(i,n) cin>>arr[i],pref[i]=pref[i-1]+arr[i],wk[i]=1;
REP(j,50005) dp[j]=0;
dp[0]=1;
REP1(i,n){
ndp[0]=i+1;
REP1(j,50004){
ndp[j]=dp[j];
if(j>=arr[i]) MXTO(ndp[j],dp[j-arr[i]]);
}
REP1(j,i){
int x=pref[i]-pref[j-1];
if(x%2 or ndp[x/2]<j) wk[i-j+1]=0;
}
REP(j,50005) dp[j]=ndp[j];
}
int cnt=0;
REP1(i,n) cnt+=wk[i];
cout<<cnt<<' ';
REP1(i,n) if(wk[i]) cout<<i<<' ';
cout<<'\n';
}
int main(){
ios::sync_with_stdio(false),cin.tie(0);
int t;
cin>>t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
596 KB |
Output is correct |
2 |
Correct |
185 ms |
836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
396 ms |
708 KB |
Output is correct |
2 |
Correct |
637 ms |
712 KB |
Output is correct |
3 |
Correct |
663 ms |
708 KB |
Output is correct |
4 |
Correct |
923 ms |
716 KB |
Output is correct |
5 |
Correct |
1346 ms |
876 KB |
Output is correct |
6 |
Correct |
1578 ms |
772 KB |
Output is correct |
7 |
Correct |
1431 ms |
1008 KB |
Output is correct |