QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#691818 | #8057. Best Carry Player 4 | xxk2006 | WA | 1ms | 7656kb | C++23 | 1.6kb | 2024-10-31 13:07:43 | 2024-10-31 13:07:45 |
Judging History
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'