QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#748655#6429. Let's Play CurlingHog_Dawa_IOIWA 0ms1656kbC++141.0kb2024-11-14 20:59:412024-11-14 20:59:41

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 20:59:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1656kb
  • [2024-11-14 20:59:41]
  • 提交

answer

#include<cstdio>
#include<algorithm>
using namespace std;
struct ss{int whi,num;}s[200005];
int n,m,sr,lsh[200005],tre[200005],cnt,t,ans;
bool c(ss a,ss b){return a.num<b.num||a.num==b.num&&a.whi<b.whi;}
int lshs(int num){return lower_bound(lsh+1,lsh+cnt+1,num)-lsh;}
void add(int wh){while(wh<=cnt) tre[wh]++,wh+=wh&(-wh);}
int ask(int a,int b){int rts=0;while(b) rts+=tre[b],b-=b&(-b);
while(a) rts-=tre[a],a-=a&(-a);return rts;}
int main()
{
    scanf("%d",&t);while(t--)
    {
        scanf("%d%d",&n,&m),ans=0;
        for(int i=1;i<=n;i++) scanf("%d",&s[i].num),s[i].whi=1;
        for(int i=1;i<=m;i++) scanf("%d",&s[i+n].num),s[i+n].whi=0;
        s[n+m+1]={0,(int)1e9+1},sort(s+1,s+n+m+1,c);
        for(int i=1;i<=n+m+1;i++) lsh[i]=s[i].num,tre[i]=0;
        cnt=unique(lsh+1,lsh+n+m+2)-lsh-1;int lst=0;bool finde=0;
        for(int i=1;i<=n+m+1;i++)
        {
            if(s[i].whi) add(lshs(s[i].num));
            else ans=max(ans,ask(lst,lshs(s[i].num))),lst=lshs(s[i].num);
        }printf("%d\n",ans);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1656kb

input:

3
2 2
2 3
1 4
6 5
2 5 3 7 1 7
3 4 3 1 10
1 1
7
7

output:

2
3
0

result:

wrong answer 3rd lines differ - expected: 'Impossible', found: '0'