Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: exoworldgd

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

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-15 23:04:17

#pragma GCC optimize("O5,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include<bits/stdc++.h>
#define exoworldgd cin.tie(0)->sync_with_stdio(0),cout.tie(0)
#define int long long
using namespace std;
const int inf = LLONG_MAX, mod = 1e9+7, maxn = 1e6+1;
signed main(void) {
    exoworldgd;
    int n,x,sum=0;
	cin >> n;
	vector<string> v;
	string s="",ans="";
	while (n--) {
		cin >> x, s= "";
		while (x) s += (x&1 ? "1" : "0"), x /= 2;
		reverse(s.begin(),s.end()), v.push_back(s);
	}
	sort(v.begin(),v.end(),[&](string a, string b) {return a+b > b+a;});
	for (string i : v) ans += i;
	for (char c : ans) sum = sum*2+(c-'0');
	cout << sum;
}