/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 1ms 388.0 KiB
#4 Accepted 38ms 1.008 MiB
#5 Accepted 6ms 636.0 KiB
#6 Accepted 46ms 1.102 MiB
#7 Accepted 26ms 872.0 KiB
#8 Accepted 34ms 984.0 KiB
#9 Accepted 48ms 1.027 MiB
#10 Accepted 50ms 1.027 MiB
#11 Accepted 49ms 1.141 MiB
#12 Accepted 32ms 796.0 KiB
#13 Accepted 62ms 1.277 MiB
#14 Accepted 62ms 1.312 MiB
#15 Accepted 62ms 1.312 MiB
#16 Accepted 61ms 1.301 MiB
#17 Accepted 61ms 1.309 MiB
#18 Accepted 60ms 1.305 MiB
#19 Accepted 61ms 1.312 MiB
#20 Accepted 61ms 1.277 MiB
#21 Accepted 51ms 1.07 MiB
#22 Accepted 48ms 1.121 MiB
#23 Accepted 23ms 1.305 MiB
#24 Accepted 22ms 1.305 MiB
#25 Accepted 34ms 1.301 MiB
#26 Wrong Answer 1ms 540.0 KiB
#27 Wrong Answer 1ms 540.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
void solve()
{
   ll n , k ; cin >> n >> k ; ll a[n] ;
    map < int , int > bit ;
   for(int i = 0 ; i < n ; i++)
   {
      cin >> a[i] ;
      for(int j = 0 ; j < 50 ; j++)
      {
         if((1LL << j) & a[i]) bit[j]++ ;
      }
   }
   ll x = 0 , Ans = 0;
   for(ll i = 50 ; i >= 0 ; i--)
   {
       ll zero = n - bit[i] ;
       ll add = x + (1LL << i) ;
      // cout << zero << " " << bit[i] << " " << k << " " << add << endl ;
       if(zero >= bit[i] && add <= k) x = add ;

   }
  // cout << x << endl ;
   for(int i = 0 ; i < n ; i++) Ans += (a[i] ^ x) ;

   cout << Ans << "\n" ;

}
int main()
{
     __Heart__
     //READ("0out.txt") ;
     int t ; t = 1 ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1054 Yet another challenge for Roy!
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-03 16:44:01
Judged At
2024-05-03 16:44:01
Judged By
Score
98
Total Time
62ms
Peak Memory
1.312 MiB