Submission #978860

#TimeUsernameProblemLanguageResultExecution timeMemory
978860VMaksimoski008Kpart (eJOI21_kpart)C++17
0 / 100
366 ms1092 KiB
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> v(n+1), dp(100005), ans(n+1, 1), res; for(int i=1; i<=n; i++) { cin >> v[i]; int sum = 0; dp[v[i]] = i; for(int j=100000; j>v[i]; j--) dp[j] = max(dp[j], dp[j-v[i]]); for(int j=i; j>=1; j--) { sum += v[j]; if(sum % 2 == 1 || dp[sum/2] < j) ans[i-j+1] = 0; } } for(int i=1; i<=n; i++) if(ans[i]) res.push_back(i); cout << res.size() << " "; for(int &x : res) cout << x << " "; cout << '\n'; } int main() { int t = 1; cin >> t; while(t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...