Submission #1128191

#TimeUsernameProblemLanguageResultExecution timeMemory
1128191rasbery303Kpart (eJOI21_kpart)C++20
0 / 100
2093 ms452 KiB
#include <iostream> #include <vector> using namespace std; const int N = 1001; int a[N]; void solve(){ int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; vector<int> ans; int sum = a[1], mx = a[1]; for (int i = 2; i <= n; ++i){ sum += a[i]; mx = max(mx, a[i]); if (sum%2) continue; //cout << "sum, i = " << sum << ' ' << i << '\n'; vector<bool> dp(100001, false); dp[0] = true; for (int j = 1; j <= i; ++j) for (int val = 100001; val >= a[j]; --val) dp[val] = dp[val] | dp[val-a[j]]; if (dp[sum/2] == 1) ans.push_back(i); } cout << ans.size() << ' '; for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " \n"[i==ans.size()-1]; } int main(){ ios::sync_with_stdio(false); //cin.tie(NULL); int tt; cin >> tt; while(tt--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...