/*
(( '-""``""-' ))
)-__-_.._-__-(
/ --- (o _ o) --- \
\ .-* ( .0. ) *-. /
_'-. ,_ '=' _, .-'_
/ ;#'#'# - #'#'#; \
\_)) -----'#'----- ((_/
# --------- #
'# ------- #'
/..-'# ------- #'-.\
_\...-\'# -- #'/-.../_
((____)- '#' -(____))
art by - Vinni01 / luchi abi
cout << fixed << setprecision(6) << x;
freopen ( "sum.in", "r", stdin )
*/
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
using namespace std ;
#define ll long long
#define dd double
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define UseOFF ios_base::sync_with_stdio(0);cin.tie(0), cout.tie(0);
#define sz size
#define ins insert
#define new jweijofdg
const ll N = 2e6 + 11 ;
ll tt = 1 ;
map < ll, ll > cnt ;
ll mx = 0 ;
map < ll, ll > mp ;
ll a[ N ] ;
vector < pair < ll, ll > > v1, v3 ;
vector < ll > v2 ;
set < ll > st ;
void solve()
{
ll n ;
cin >> n ;
bool b = 0 ;
ll pos = 0 ;
ll sum = 0 ;
for( int i = 0 ; i < n ; i++ )
{
cin >> a[ i ] ;
sum += a[ i ] ;
}
set < ll > st ;
for( int k = 1 ; k <= sum ; k++ )
{
ll cnt = 0 ;
for( int l = -1 ; l < n ; l++ )
{
ll prev ;
if( l >= 0 ) prev = a[ l ] ;
if( l >= 0 ) a[ l ] = 0 ;
for( int i = 1 ; i < ( 1 << n ) ; i++ )
{
ll sum1 = 0, sum2 = 0 ;
for( int j = 0 ; j < n ; j++ )
{
if( ( i >> j ) & 1 )
{
sum1 += a[ j ] ;
}
else sum2 += a[ j ] ;
}
ll d = abs( sum1 - sum2 ) ;
if( k == d )
{
//cout << k << " || " << sum1 << " " << sum2 << " " << cnt + 1 << " || " << l << '\n' ;
cnt++ ;
break ;
}
}
if( l >= 0 ) a[ l ] = prev ;
}
if( cnt == n + 1 )
{
st.ins( k ) ;
}
}
cout << st.sz() << '\n' ;
for( auto to : st )
{
cout << to << " " ;
}
}
signed main()
{
while( tt-- )
{
solve() ;
}
}
Compilation message
bootfall.cpp: In function 'void solve()':
bootfall.cpp:69:7: warning: unused variable 'b' [-Wunused-variable]
69 | bool b = 0 ;
| ^
bootfall.cpp:70:5: warning: unused variable 'pos' [-Wunused-variable]
70 | ll pos = 0 ;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |