Submission

Status:

TTTTTTTTTT

Subtask/Task Score:

0/100

Score: 0

User: aomILOVEMYFRIEND

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

Language: cpp

Time: 1.097 second

Submitted On: 2025-10-09 23:49:46

/*#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    string F="";
    cin >>n;
    vector<int> arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    
    //fixed to เลขฐาน 2 in arr[]
    for(int i = 0;i <n;i++){
        int x = arr[i];
        string bin = "";
        if (x == 0) bin = "0";
        while(x > 0){
            bin = char('0' + x % 2) + bin; // เอาเศษ (bit) มาต่อหน้า
            x /= 2;
        }
        F+=bin;
    }
    
}*/
/*#include <bits/stdc++.h>
using namespace std;

#define ull unsigned long long

int n;
ull num[4];
bool used[4] = {0};

ull join_num(ull curr[4]){
    ull joined=0;int count=0;
    for(int i = 0;i < n;i++){
        int index;
        for(int j = 0;j < sizeof(curr[i]) * 8 - 1;j++){
            if(((curr[i]>>j)&1)==1){
                index=j+1;
            }
        }
        joined = joined|(curr[i]<<count);
        count+=index;
    }
    return joined;
}

ull find_max(ull curr[4], int pos){
    if(pos==n){
        return join_num(curr);
    }
    unsigned long long max=0;
    for(int i = 0;i < n;i++){
        if(!used[i]){
            used[i] = 1;
            curr[pos] = num[i];
            int get_ans = find_max(curr, pos+1);
            if(get_ans>max){
                max=get_ans;
            }
            used[i] = 0;
        }
    }
    return max;
}

int main(){
    // input
    cin>>n;
    for(int i = 0;i < n;i++)cin>>num[i];
    
    // find max answer
    ull blank[4];
    cout<<find_max(blank, 0);
    
    return 0;
}*/
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
int n,temp,temp1,temp2;
class cmp{
    public:
    bool operator()(string a,string b){
        temp2=max(a.size(),b.size());
        for(int i=0;i<temp2;i++){
            if(i==a.size()){
                return false;
            }
            if(i==b.size()){
                return true;
            }
            if(a[i]>b[i]){
                return false;
            }
            if(b[i]>a[i]){
                return true;
            }
        }
        return false;
    }
};
string s;
priority_queue<string,vector<string>,cmp> pq;
int main(){
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>temp;
        s="";
        temp1=1;
        while(temp1<=temp){
            temp1=2;
        }
        temp1/=2;
        while(temp1>0){
            if(temp1<=temp){
                temp-=temp1;
                s+="1";
            }
            else{
                s+="0";
            }
            temp1/=2;
        }
        pq.push(s);
    }
    s="";
    while(!pq.empty()){
        s+=pq.top();
        pq.pop();
    }
    temp1=1;
    temp2=0;
    while(temp2<s.size()){
        temp1=2;
        temp2+=1;
    }
    temp1/=2;
    n=0;
    temp2=0;
    while(temp1>0){
        if(s[temp2]=='1'){
            n+=temp1;
        }
        temp1/=2;
        temp2+=1;
    }
    cout<<n;
}