QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#942756 | #8332. Two in One | DiaoTianhao | WA | 0ms | 3584kb | C++14 | 659b | 2025-03-19 13:31:40 | 2025-03-19 13:31:41 |
Judging History
answer
#include <bits/stdc++.h>
int calc(int a, int b) {
int d = a | b, e = a & b;
while(e & (e - 1))
e &= e - 1;
return d | std::max(e, e - 1);
}
int cnt[131072], a[131072], T, n;
int main() {
std::cin >> T;
while(T--) {
std::cin >> n;
for(int i = 1; i <= n; i++)
cnt[i] = 0;
for(int i = 1; i <= n; i++)
std::cin >> a[i], cnt[a[i]]++;
std::sort(cnt + 1, cnt + n + 1, std::greater<int>());
int max = 0;
for(int i = 2; i <= n; i++)
max = std::max(max, calc(cnt[1], cnt[2]));
std::cout << max << '\n';
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
1 7 1 2 3 4 3 2 1
output:
2
result:
wrong answer 1st numbers differ - expected: '3', found: '2'