QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#691818#8057. Best Carry Player 4xxk2006WA 1ms7656kbC++231.6kb2024-10-31 13:07:432024-10-31 13:07:45

Judging History

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

  • [2024-10-31 13:07:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7656kb
  • [2024-10-31 13:07:43]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define Enter putchar('\n')
#define spc putchar(' ')
#define pb push_back
#define fi first
#define se second
inline void read(int &num){num=0;int f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){num=(num<<1)+(num<<3)+(ch^48);ch=getchar();}num*=f;}
inline void lread(long long &num){num=0;int f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){num=(num<<1)+(num<<3)+(ch^48);ch=getchar();}num*=f;}
void print(long long num){if(num<0){putchar('-');num=-num;}if(num>9){print(num/10);}putchar((num%10)^48);}
const int N=5e5+9;
LL a[N],b[N],g[N];
int main(){
    int T,n;
    read(T);
    while(T--){
        read(n);
        int ma=0,mb=0,xa=0,xb=0;
        for(int i=0;i<n;i++){
            lread(a[i]);
            if(a[i])ma=i;
        }
        for(int i=0;i<n;i++){
            lread(b[i]);
            if(b[i])mb=i;
        }
        if(ma+mb<n){
            puts("0");
            continue;
        }
        g[n]=0;
        for(int i=n-1;~i;i--)g[i]=g[i+1]+b[i];
        LL ans=0;
        for(int i=0;i<n;i++){
            ans+=min(a[i],g[n-i-1]-ans);
            a[i]=max((LL)0,a[i]-g[n-i+1]+ans);
            b[n-i-1]=min(b[n-i-1],g[n-i-1]-ans);
        }
        for(int i=0;i<n;i++){
            if(a[i])xa=i;
            if(b[i])xb=i;
        }
        if(xa+mb>=n-1||xb+ma>=n-1)print(ans);
        else print(ans-1);
        Enter;
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7656kb

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:

3
1
2
467900
29

result:

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