QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#392593 | #8332. Two in One | Yia# | WA | 0ms | 3588kb | C++17 | 760b | 2024-04-17 17:44:06 | 2024-04-17 17:44:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
//#define int long long
const int N=1e5+10;
int n,m1,m2;
bool cmp(int p,int q){
return p>q;
}
void solve(){
int x;
cin>>n;
vector<int>a(n+1);
for(int i=1;i<=n;i++){
cin>>x;
a[x]++;
}
sort(a.rbegin(),a.rend());
for(int i=1;i<=n;i++){
if(a[i]!=a[0]){
m2=a[i];
break;
}
if(a[i]==0){
m2=a[i-1];
break;
}
}
int ans=m1;
int cnt=1;
while(cnt<m2){
cnt*=2;
}
cnt-=1;
ans=max(cnt|m1,cnt|m2);
ans=max(ans,m1|m2);
cout<<ans<<endl;
}
signed main() {
int T;
cin>>T;
while(T--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3588kb
input:
1 7 1 2 3 4 3 2 1
output:
1
result:
wrong answer 1st numbers differ - expected: '3', found: '1'