# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1128103 | BilAktauAlmansur | Bootfall (IZhO17_bootfall) | C++17 | 602 ms | 2636 KiB |
#include <bits/stdc++.h>
#pragma optimize("g", on)
// #pragma GCC optimize ("inline")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
void Freopen () {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
using namespace std;
#define fi first
#define se second
// #define int long long
const int N = 250000 + 7, M = 250000;
short int n, a[507];
int us[N];
signed main() {
// freopen("duty.in", "r", stdin);
// freopen("duty.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// cout.tie(NULL);
//Freopen();
cin>>n;
for(short int i = 1; i <= n; i++) {
cin>>a[i];
}
sort(a + 1, a + 1 + n);
int need = accumulate(a + 1, a + 1 + n, 0);
for(int i = 1; i <= need; i++)us[i] = 1;
if(need % 2 == 1) {
cout << "0\n";
return 0 ;
}
need /= 2;
bitset<M> st;
st[0] = 1;
for(int i = 1; i <= n; i++)st |= (st << a[i]);
if(!st[need]) {
cout << "0\n";
return 0;
}
st.reset();
need *= 2;
st[0] = 1;
for(int j = 1; j <= n; j++) {
bitset<M> ts = st;
for(int i = j + 1; i <= n; i++)ts |= (ts << a[i]);
int s = 1;
if(a[1] % 2 == 0)s ++;
for(int i = s; i <= need; i += 2) {
if(!us[i])continue;
int W = need + i - a[j];
if(W % 2 == 1) {
us[i] = 0;
continue;
}
if(!ts[W / 2])us[i] = 0;
}
st |= (st << a[j]);
}
vector<int> ans;
int s = 1;
if(a[1] % 2 == 0)s ++;
for(int i = s; i <= need; i += 2)if(us[i])ans.push_back(i);
cout << ans.size() << '\n';
for(auto j : ans)cout << j << ' ';
cout << '\n';
}
/*
please AC
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |