제출 #1130653

#제출 시각아이디문제언어결과실행 시간메모리
1130653zhasynBootfall (IZhO17_bootfall)C++20
44 / 100
439 ms1348 KiB
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 250000 + 100, M = 4096 + 10, len = 315, inf = 1e18;
const ll mod = 1e9 + 7;
ll um(ll a, ll b){
	return (1LL * a * b) % mod;
}
ll subr(ll a, ll b){
	return ((1LL * a - b) % mod + mod) % mod;
}
int arr[N];
bool was[N], ans[N];
int main() {
	int n, sm = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
		sm += arr[i];
	}
	bitset <112600> cur;
	cur[0] = 1;
	for(int i = 1; i <= n; i++){
		cur |= (cur << arr[i]);
	}
	if(sm % 2 == 1 || cur[sm/2] == 0){
		cout << 0;
		return 0;
	}
	
	
	
	for(int i = 1; i <= n; i++){
		bitset <112600> b;
		b[0] = 1;
		for(int j = 1; j <= n; j++){
			if(i == j) continue;
			b |= (b << arr[j]);
		}
		for(int j = 0; j <= sm; j++){
			if(b[j]){
				was[abs(sm - arr[i] - j - j)] = 1;
			}
		}
		for(int j = 0; j <= sm; j++){
			if(i == 1) ans[j] = was[j];
			else ans[j] &= was[j];
			was[j] = false;
			//cout << was[j] << " ";
		}
		//cout << endl;
	}
	vector <int> vec;
	for(int i = 0; i <= sm; i++){
		if(ans[i]) vec.pb(i);
	}
	
	cout << (int)vec.size() << endl;
	for(auto u : vec){
		cout << u << " ";
	}
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...