QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#943874 | #8332. Two in One | DLYdly1105 | WA | 1ms | 3840kb | C++14 | 856b | 2025-03-20 08:20:23 | 2025-03-20 08:20:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int T,n,x,y,ans,max1,max2,a[N],cnt[N];
int main()
{
scanf("%d",&T);
while(T--)
{
ans=max1=max2=-1;
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&a[i]),cnt[a[i]]++;
for(int i=1;i<=n;i++)
{
cout<<cnt[i]<<" ";
if(cnt[i]>max1)max2=max1,y=x,max1=cnt[i],x=i;
else if(cnt[i]>max2)max2=cnt[i],y=i;
}
if(max2==-1)printf("%d\n",max1);
else
{
ans=max1|max2;
for(int i=n;i>=1;i--)
{
if(a[i]==x)max1--;
if(a[i]==y)max2--;
ans=max(ans,(max1|max2));
}
printf("%d\n",ans);
}
for(int i=1;i<=n;i++)cnt[i]=0;
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3840kb
input:
1 7 1 2 3 4 3 2 1
output:
2 2 2 1 0 0 0 3
result:
wrong answer 1st numbers differ - expected: '3', found: '2'