Subtask #2: Accepted
but
Subtask #1: WA
Can you please tell me what is wrong and how to solve Subtask #1…!!!
void solve()
{
fast;
multimap<ll,ll,greater>mp;
ll n,k;
cin>>n>>k;
ll a[n],max=0;
input(a,n);
int i;
for(i=0;i<=32;i++)
{
ll sum=0;
ll sb=1LL<<i;
for(ll j=0;j<n;j++) sum+=(ll)sb&a[j];
mp.insert(make_pair(sum,i));
}
ll ans=0;
multimap<ll,ll,greater>::iterator it;
for(it=mp.begin();it!=mp.end() && k>0;it++,k–) ans+=(ll)1LL<<(it->second);
cout<<ans<<endl;
return;
}