/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 536.0 KiB
#3 Wrong Answer 1ms 532.0 KiB
#4 Accepted 22ms 1.168 MiB
#5 Accepted 4ms 676.0 KiB
#6 Accepted 28ms 1.609 MiB
#7 Accepted 15ms 1.062 MiB
#8 Accepted 19ms 1.129 MiB
#9 Accepted 27ms 1.535 MiB
#10 Accepted 28ms 1.621 MiB
#11 Accepted 27ms 1.531 MiB
#12 Accepted 17ms 1.129 MiB
#13 Accepted 34ms 1.562 MiB
#14 Accepted 33ms 1.582 MiB
#15 Accepted 34ms 1.625 MiB
#16 Accepted 33ms 1.672 MiB
#17 Accepted 33ms 1.613 MiB
#18 Accepted 33ms 1.434 MiB
#19 Accepted 34ms 1.434 MiB
#20 Accepted 35ms 1.676 MiB
#21 Accepted 29ms 1.637 MiB
#22 Accepted 27ms 1.527 MiB
#23 Accepted 18ms 1.453 MiB
#24 Accepted 22ms 1.434 MiB
#25 Accepted 25ms 1.582 MiB
#26 Wrong Answer 1ms 324.0 KiB

Code

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

#define ll unsigned long long
#define endl '\n'
const int N = 1e6+4;

void solve(int cs){
    int n;cin>>n;
    ll k;cin>>k;
    std::vector<ll>v ;
    
    int bit[50] = {0};
    for(int i = 0; i < n; i++){
        ll a;cin>>a;
        v.push_back(a);
        for(int j = 0; j < 46; j++){
            if((a&(1ll<<j)))bit[j]++;
        }
    }
    //cout<<(3&4) <<" "<<(1&4) <<" "<<(6&4)<<endl;
    //cout<<bit[2]<<endl;
    ll ans = 0;
    ll tm = 0;
    for(int i = 45; i>=0; i--){
        int unset = n-bit[i];
        
        if(bit[i] < unset){
            if((tm|(1ll<<i)) <= k){
                tm |= (1ll<<i);
            }
        }
    }
    if(tm == 0)tm = 1;
    for(auto u:v){
        ans += (u^tm);
    }
    cout<<ans<<endl;
}
   
int main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);
    int t=1,cs=0;
    //cin >> t;
    while(t--)
    {
        solve(++cs);
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1054 Yet another challenge for Roy!
Contest
Brain Booster #3
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 17:34:11
Judged At
2024-11-11 03:32:07
Judged By
Score
97
Total Time
35ms
Peak Memory
1.676 MiB