/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Wrong Answer 1ms 320.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
// #define cerr cout
#include "algo/debug.h"
#else
#define deb(...) 30
#endif
#define ll long long
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, k;
    cin >> n >> k;
    ll x = 0, ans = 0, lst = 0;
    f(i, k) if (k >> i & 1) lst = i;
    vector<int> v(n);
    int cnt[31];
    f(i, n) cin >> v[i];
    f(i, n) {
        f(j, 30) {
            if (v[i] >> j & 1)
                cnt[j]++;
        }
    }
    ans = 0;
    for (int k = 0; k <= lst; k++) {
        if (cnt[k] < n - cnt[k]) {
            ans |= (1 << k);
        }
    }
    ll mx = 0, mx2 = 0;
    for (auto a : v)
        mx += (a ^ ans), mx2 += (a ^ k);
    cout << max(mx, mx2) << '\n';
    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:04:42
Judged At
2024-11-11 03:32:35
Judged By
Score
1
Total Time
1ms
Peak Memory
532.0 KiB