Submission #167691

#TimeUsernameProblemLanguageResultExecution timeMemory
167691muhammad_hokimiyonBootfall (IZhO17_bootfall)C++14
65 / 100
408 ms262148 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define fi first #define se second #define ll long long using namespace std; const int N = 3e5 + 7; const int mod = 1e9 + 7; int n; int a[N]; int d[N]; int d1[510][N]; vector < int > v[N]; void solve() { cin >> n; int sum = 0; for( int i = 1; i <= n; i++ ){ cin >> a[i]; sum += a[i]; } d[0] = 1; for( int i = 1; i <= n; i++ ){ for( int j = sum; j >= 0; j-- ){ if( j - a[i] >= 0 ){ d[j] += d[j - a[i]]; } } } if( sum % 2 ){ cout << "0\n"; return; } for( int i = 1; i <= n; i++ ){ for( int j = 0; j <= sum; j++ ){ d1[i][j] = d[j]; if( j - a[i] >= 0 ){ d1[i][j] -= d1[i][j - a[i]]; } } } if( !d[sum / 2] ){ cout << "0\n"; return; } vector < int > ans; for( int i = 1; i <= sum; i++ ){ bool f = false; for( int j = 1; j <= n; j++ ){ int x = sum - a[j] + i; if( x % 2 )f = true; if( !d1[j][x / 2] )f = true; } if( !f )ans.push_back(i); } cout << (int)ans.size() << "\n"; for( auto x : ans ){ cout << x << " "; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen( "input.txt" , "r" , stdin ); //freopen( "output.txt" , "w" , stdout ); int t = 1;//cin >> t; while( t-- ){ solve(); } }
#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...