/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 524.0 KiB
#2 Wrong Answer 1ms 532.0 KiB

Code

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

#define int long long

int32_t main () {
  cin.tie(0)->sync_with_stdio(0);
  int n, k, ans = 0, sum = 0;
  cin >> n >> k;
  int a[n];
  int bt[42]{};
  int ct[42]{};
  for (int i = 0; i < n; i++) {
      cin >> a[i];
      int pos = 0, cnt = 41;
      while (cnt--) {
          if (a[i]%2 == 0) {
              bt[pos]++;
          }
          else ct[pos]++;
          pos++;
          a[i] /= 2;
      }
  }
  for (int i = 0; i < 42; i++) {
      bt[i] *= (1LL<<i);
      ct[i] *= (1LL<<i);
  }
  for (int i = 41; i >= 0; i--) {
      if ((1LL<<i)&k) {
          int tot = 0;
          for (int j = 0; j < i; j++) {
              tot += max (bt[j], ct[j]);
          }
          ans = max (ans, tot+sum+ct[i]);
          sum += bt[i];
      }
      else sum += ct[i];
  }
  ans = max (ans, sum);
  cout << ans;
}

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:10:41
Judged At
2024-11-11 03:32:30
Judged By
Score
0
Total Time
1ms
Peak Memory
532.0 KiB