제출 #1128190

#제출 시각아이디문제언어결과실행 시간메모리
1128190rasbery303Kpart (eJOI21_kpart)C++20
0 / 100
124 ms476 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(sum+1, false); dp[0] = true; for (int j = 1; j <= i; ++j) for (int val = 2*mx; 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...