QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#450420#8057. Best Carry Player 4xiaozengXWA 0ms5616kbC++141.2kb2024-06-22 12:20:172024-06-22 12:20:17

Judging History

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

  • [2024-06-22 12:20:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5616kb
  • [2024-06-22 12:20:17]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

int stk[100050],tp=0;
int a[1000050],b[1000050],m;
int cnta,cntb;
long long ans=0;
bool fuck=false;
int lst=0;
void cmp(int p1,int p2){
    int r=min(a[p1],b[p2]);
    a[p1]-=r;b[p2]-=r;
    if(r>0)lst=p1;
    if(r>0&&p1+p2>=m)fuck=true;
    if(b[p2]>0)stk[++tp]=p2;
    ans+=r;
}
int main(){
    int t;cin>>t;while(t--){
        tp=0;
        cin>>m;
        cnta=cntb=0;ans=0;
        int mx;
        for(int i=0;i<m;i++){cin>>a[i];cnta+=a[i];if(a[i])mx=i;}
        for(int i=0;i<m;i++){cin>>b[i];cntb+=b[i];}
        a[mx]--;
        cnta++;cntb++;
        if(cnta>cntb){b[0]+=cnta-cntb;}else{a[0]+=cntb-cnta;}
        for(int i=0;i<m;i++){
            stk[++tp]=m-i-1;    
            while(a[i]){
                if(tp==0)break;
                else{tp--;cmp(i,stk[tp+1]);}
            }
        }
        int op=0;
        for(int i=0;i<m;i++){
            if(i+mx>=m&&b[i]){
                cout<<ans<<endl;
                op=1;
                break;
            }
        }
        if(op==0)cout<<0<<endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
2
1 2
3 4
3
1 0 1
0 1 0
4
1 0 0 1
1 1 1 1
5
123456 114514 1919810 233333 234567
20050815 998244353 0 0 0
10
5 3 5 3 2 4 2 4 1 5
9 9 8 2 4 4 3 5 3 0

output:

0
0
1
467899
28

result:

wrong answer 1st numbers differ - expected: '5', found: '0'