/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 1ms 320.0 KiB
#4 Wrong Answer 37ms 1016.0 KiB
#5 Wrong Answer 6ms 592.0 KiB

Code

#include <iostream>
#include <vector>
using namespace std;

long long m(vector<long long>& a, long long k) {
    long long m_f = 0;
    long long mask = 1LL << 60;
    
    while (mask > 0) {
        long long c_1 = 0;
        for (long long a_val : a) {
            if (a_val & mask)
                c_1++;
        }
        
        if ((k & mask) && c_1 <= a.size() - c_1) {
            m_f |= mask;
        }
        
        mask >>= 1;
    }
    
    long long result = 0;
    for (long long a_val : a) {
        result += a_val ^ m_f;
    }
    
    return result;
}

int main() {
    int n;
    long long k;
    cin >> n >> k;
    
    vector<long long> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    
    cout << m(a, k) << endl;
    
    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 15:50:26
Judged At
2024-11-11 03:33:49
Judged By
Score
3
Total Time
37ms
Peak Memory
1016.0 KiB