Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: zenta4u

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

Language: cpp

Time: 0.004 second

Submitted On: 2025-10-03 11:57:46

// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
string bin(int x){
    string s="";
    while(x>0){
        s=to_string(x%2)+s;
        x/=2;
    }
    return s;
}
bool comp(int a,int b){
    return bin(a)+bin(b)>bin(b)+bin(a);
}
int main() {
    int N;cin>>N;
    int x[N],binary;

    for(int i=0;i<N;i++){
        cin>>x[i];
    }
    sort(x,x+N,comp);
    string ans="";
    for(int i=0;i<N;i++){
        ans+=bin(x[i]);
    }
    cout << stoi(ans,nullptr,2);
}