Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: mumumimi
Problemset: วิศวกรรมข้อมูล
Language: cpp
Time: 0.002 second
Submitted On: 2026-10-12 15:26:04
#include <bits/stdc++.h>
using namespace std;
string bi(int n){
string result ="";
while(n>0){
result = result + char(n%2+'0');
n/=2;
}
reverse(result.begin(),result.end());
return result;
}
bool cmp(string a,string b){
return a+b>b+a;
}
int main(){
int n;cin >> n;
vector<string> v;
for(int i=0;i<n;i++){
int x;cin >> x;
v.push_back(bi(x));
}
sort(v.begin(),v.end(),cmp);
string s = "";
for(auto c:v){
s+=c;
}
unsigned long long total = stoull(s,nullptr,2);
cout << total;
}