Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: gay69
Problemset: วิศวกรรมข้อมูล
Language: cpp
Time: 0.003 second
Submitted On: 2025-10-12 17:25:31
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
string arr[n];
for (int i = 0; i < n; i++) {
int x;
cin >> x;
string res = "";
if (x == 0) {
res = "0";
}
while (x > 0) {
res.push_back(x % 2 + '0');
x /= 2;
}
reverse(res.begin(), res.end());
arr[i] = res;
}
sort(arr, arr + n);
int most = 0;
do {
int res = 0;
for (int i = 0; i < n; i++) {
int m = arr[i].size();
for (int j = 0; j < m; j++) {
res = 2 * res + (arr[i][j] - '0');
}
}
most = max(most, res);
} while (next_permutation(arr, arr+ n));
cout << most << "\n";
return 0;
}