답안 #1089386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1089386 2024-09-16T11:09:17 Z vjudge1 Kpart (eJOI21_kpart) C++17
100 / 100
1353 ms 1364 KB
//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();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 17 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 600 KB Output is correct
2 Correct 188 ms 800 KB Output is correct
3 Correct 240 ms 844 KB Output is correct
4 Correct 489 ms 856 KB Output is correct
5 Correct 951 ms 1364 KB Output is correct
6 Correct 1353 ms 1260 KB Output is correct
7 Correct 1280 ms 1240 KB Output is correct