Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: patsa_v
Problemset: วิศวกรรมข้อมูล
Language: cpp
Time: 0.003 second
Submitted On: 2025-10-14 19:47:56
#include <bits/stdc++.h>
using namespace std;
string convert(int n){
string s = "";
while(n > 0)
{
s = to_string(n%2) + s;
n/=2;
}
return s;
}
int main(){
int n;
cin >> n;
vector<int> v;
for(int i = 0;i<n;i++){
int g;
cin >> g;
v.push_back(g);
}
sort(v.begin(),v.end());
string temp = "";
int max = 0;
do {
for (auto i: v) temp += convert(i);
int sum = 0;
for(int i = 0; i < temp.size() ; i++){
sum += (temp[i] - '0') * pow(2,temp.size()-i-1);
}
if(sum > max){
max = sum;
}
temp.clear();
} while (next_permutation(v.begin(), v.end()));
cout << max;
return 0;
}