제출 #1151259

#제출 시각아이디문제언어결과실행 시간메모리
1151259andrei_nKpart (eJOI21_kpart)C++20
30 / 100
1493 ms3124 KiB
#include <bits/stdc++.h> using namespace std; bool dp[1005][50005]; int v[1005]; int fr[1005]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T; cin>>T; while(T--) { int n; cin>>n; for(int i=1; i<=n; ++i) { cin>>v[i]; fr[i] = 0; } for(int i=1; i<=n; ++i) { int LIMIT = min(50000, 200000/(n-i+1)); for(int j=0; j<=n-i+1; ++j) for(int k=0; k<=LIMIT; ++k) dp[j][k] = 0; dp[0][0] = 1; for(int j=i; j<=n; ++j) { for(int k = 0; k <= LIMIT; ++k) if(dp[j-i][k]) { if(k + v[j] <= LIMIT) dp[j-i+1][k + v[j]] = 1; dp[j-i+1][abs(k - v[j])] = 1; } if(dp[j-i+1][0]) ++fr[j-i+1]; } } vector<int> ok; for(int i=1; i<=n; ++i) if(fr[i] == n - i + 1) ok.push_back(i); cout<<ok.size(); for(auto &i : ok) cout<<' '<<i; cout<<'\n'; } return 0; } /* 2 7 7 3 5 1 3 3 5 6 1 2 3 5 8 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...