Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Nitro_Legacy

Problemset: วิศวกรรมข้อมูล

Language: cpp

Time: 0.004 second

Submitted On: 2026-09-28 22:10:27

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string dtb(int n){
    string s = "";
    while (n > 0){
        if (n % 2 == 0){
            s += "0";
        } else {
            s += "1";
        }
        n /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}
int main(){
    int n;
    cin >> n;
    vector<string> v;

    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        v.push_back(dtb(x));
    }
    ll mx = 0;
    sort(v.begin(), v.end());
    do{
        string s = "";
        for (int i = 0; i < n; i++){
            s += v[i];
        }
        mx = max(mx, stoll(s, nullptr, 2));
    } while(next_permutation(v.begin(), v.end()));
    cout << mx;
    return 0;
}