-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10264.cpp
More file actions
53 lines (51 loc) · 950 Bytes
/
Copy path10264.cpp
File metadata and controls
53 lines (51 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n;
while( scanf("%d",&n)!=EOF )
{
int ma;
ma=-9999999;
int t=(1<<n);
// cout<<t<<endl;
vector<int> vec(t);
vector< int > vv;
for( int i = 0 ; i < t ; ++i )
{
scanf("%d",&vec[i]);
}
for( int i = 0 ; i < t ; ++i )
{
int temp=0;
for( int j = 0 ; j < n ; ++j )
{
int p=i^(1<<j);
temp+=vec[p];
// cout<<i<<" "<<vec[p]<<" "<<p<<endl;
}
vv.push_back(temp);
}
vector<bool> pas(t,false);
for( int i =0 ; i < t;++i)
{
int temp=vv[i];
pas[i]=true;
for( int j = 0 ; j < n ; ++j )
{
int p=i^(1<<j);
if(!pas[p]){
int tt=temp+vv[p];
// cout<<i<<" "<<vec[p]<<" "<<p<<endl;
if(ma<tt)
{
ma=tt;
}
}
}
}
printf("%d\n",ma);
}
return 0;
}