# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
582646 | 2022-06-24T08:01:41 Z | temporary_juggernaut | Kpart (eJOI21_kpart) | C++14 | 1136 ms | 196036 KB |
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; typedef long long ll; typedef long double ld; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef juggernaut #define printl(args...) printf(args) #else #define printl(args...) 0 #endif int a[1005]; bool can[1005]; int dp[1005][50005]; int pref[1005]; int main(){ int test; scanf("%d",&test); while(test--){ int n; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); pref[i]=pref[i-1]+a[i]; can[i]=true; } for(int i=1;i<=n;i++){ for(int j=0;j<a[i];j++)dp[i][j]=dp[i-1][j]; for(int j=a[i];j<50005;j++)dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i]]); dp[i][a[i]]=i; for(int j=1;j<=i;j++){ int sum=pref[i]-pref[j-1]; if(sum&1)can[i-j+1]=0; else if(dp[i][sum>>1]<j)can[i-j+1]=0; } } int cnt=0; for(int i=1;i<=n;i++)cnt+=can[i]; printf("%d ",cnt); for(int i=1;i<=n;i++)if(can[i])printf("%d ",i); printf("\n"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 6100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 13408 KB | Output is correct |
2 | Correct | 125 ms | 23132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 262 ms | 50396 KB | Output is correct |
2 | Correct | 429 ms | 75396 KB | Output is correct |
3 | Correct | 431 ms | 85056 KB | Output is correct |
4 | Correct | 592 ms | 110624 KB | Output is correct |
5 | Correct | 895 ms | 171472 KB | Output is correct |
6 | Correct | 1136 ms | 192984 KB | Output is correct |
7 | Correct | 1014 ms | 196036 KB | Output is correct |