QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#943874#8332. Two in OneDLYdly1105WA 1ms3840kbC++14856b2025-03-20 08:20:232025-03-20 08:20:23

Judging History

This is the latest submission verdict.

  • [2025-03-20 08:20:23]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3840kb
  • [2025-03-20 08:20:23]
  • Submitted

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'