제출 #1089386

#제출 시각아이디문제언어결과실행 시간메모리
1089386vjudge1Kpart (eJOI21_kpart)C++17
100 / 100
1353 ms1364 KiB
//don't copy pls) /*TAAK ZDES NADO RECURSIU PISAT*/ //I'm not in the danger i am the DANGER #include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #define ll long long #define pb push_back #define int long long #define F first #define S second #define all(x) (x).begin(), (x).end() #define pii pair<int,int> #define sigma signed using namespace std; using namespace __gnu_pbds; const int N = 1e5 + 5; int mod = 1e9 + 7; const int INF = 1e18; int n,a[N],p[N],dp[N]; void Gold(){ cin >> n; set <int> ans; for(int i = 1 ; i <= n ; i++){ cin >> a[i]; ans.insert(i); p[i] = p[i - 1] + a[i]; } for(int i = 0 ; i <= p[n] ; i++){ dp[i] = 0; } for(int i = 1 ; i <= n ; i++){ for(int j = p[n] ; j >= a[i] ; j--){ dp[j] = max(dp[j] , dp[j - a[i]]); } dp[a[i]] = i; for(int j = 1 ; j <= i - 1 ; j++){ int sum = p[i] - p[j - 1]; if(sum % 2 || dp[sum / 2] < j){ ans.erase(i - j + 1); } } } ans.erase(1); cout << ans.size() << ' '; for(auto it : ans){ cout << it << ' '; } cout << '\n'; } sigma main(){ //freopen("txt.in","r",stdin); //freopen("txt.out","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); srand(time(0)); int TT = 1; cin >> TT; for(int i = 1 ; i <= TT ; i++){ //cout << "Case " << i << ": "; Gold(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...