Submission
Status:
PPPPPPPPPP
Score: 100
User: hmmm
Problemset: วิศวกรรมข้อมูล
Language: cpp
Time: 0.002 second
Submitted On: 2025-03-13 15:30:33
#include<bits/stdc++.h>
using namespace std;
const int N=5;
int a[N];
bool vis[N];
vector<int> p;
int n;
unsigned long long mx=0;
inline void rec(int x){
if(x==n){
string str;
for(auto e:p){
string s;
// cout << e << ' ';
while(e){
if(e%2==1) s+='1';
else s+='0';
e/=2;
}
reverse(s.begin(),s.end());
str+=s;
// cout << s << ' ';
}
unsigned long long cnt=0;
for(auto e:str){
cnt+=e-'0';
cnt*=2;
}
// cout << "\n";
// cout << str << "\n";
mx=max(mx,cnt);
}
for(int i=1;i<=n;i++){
if(vis[i]) continue;
vis[i]=true;
p.push_back(a[i]);
rec(x+1);
vis[i]=false;
p.pop_back();
}
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin >> n;
for(int i=1;i<=n;i++) cin >> a[i];
rec(0);
cout << mx/2;
}