QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#937736#8057. Best Carry Player 4Yurily#WA 0ms9956kbC++201.4kb2025-03-16 16:23:592025-03-16 16:23:59

Judging History

This is the latest submission verdict.

  • [2025-03-16 16:23:59]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 9956kb
  • [2025-03-16 16:23:59]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int MAX=5e5+5;
int m;
int a[MAX],b[MAX];
int a1[MAX],b1[MAX];
void sol(){
    cin>>m;
    for(int i=0;i<m;++i){
        cin>>a[i];
    }
    for(int i=0;i<m;++i){
        cin>>b[i];
    }

    long long ans=0;
    for(int i=1;i<m-1;++i)
        ans+=min(a[i],b[m-1-i]);
    ans+=a[m-1]+b[m-1];    
    for(int i=1;i<m-1;++i)
        a1[i]=a[i]-min(a[i],b[m-1-i]);
    for(int i=1;i<m-1;++i)
        b1[i]=b[i]-min(b[i],a[m-1-i]);
    
    a1[m-1]=b1[m-1]=0;

    long long tot=0,sum=0;
    for(int i=1;i<m-1;++i){
        sum+=b1[m-i];
        int cur=min((long long)a1[i],sum);
        tot+=cur;
        a1[i]-=cur;
        sum-=cur;
    }
    if(tot){
        ans+=tot;
        cout<<ans<<"\n";
    }
    else{
        int pa=m-1;
        while(pa>=0&&!a[pa])
            pa--;
        if(pa>=0){
            int pb=-1;
            for(int i=m-pa;i<=m;++i){
                if(b[i]){
                    pb=i;
                    break;
                }
            }
            if(pb==-1){
                cout<<0<<"\n";
            }
            else{
                cout<<ans<<"\n";
            }
        }
        else{
            cout<<0<<"\n";
        }
    }
}

int main(){

    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int T;
    cin>>T;
    while(T--)
        sol();

    return 0;
}

詳細信息

Test #1:

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

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:

6
1
2
467900
29

result:

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