QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#709003 | #8057. Best Carry Player 4 | frankly6 | WA | 0ms | 7696kb | C++17 | 1.4kb | 2024-11-04 10:42:46 | 2024-11-04 10:42:47 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
const int MX=500050;
const int inf=1e15;
int T, N;
int ar[MX], br[MX], suf[MX];
int read()
{
int r=0, f=1; char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
while(ch>='0'&&ch<='9') {r=r*10+ch-'0'; ch=getchar();}
return r*f;
}
signed main()
{
// freopen("testdata.in","r",stdin);
T=read();
while(T--)
{
N=read();
for(int i=0;i<N;i++) ar[i]=read();
for(int i=0;i<N;i++) br[i]=read();
int sum=0, suf=0, tag=1;
for(int i=1;i<N-1;i++)
{
suf+=br[N-1-i];
int num=min(ar[i],suf);
suf-=num;
sum+=num;
if(suf!=0) tag=0;
// cout << "suf=" << suf << '\n';
}
for(int i=1;i<N-1;i++)
{
suf+=ar[N-1-i];
int num=min(br[i],suf);
suf-=num;
sum+=num;
if(suf!=0) tag=0;
// cout << "suf=" << suf << '\n';
}
sum/=2;
sum+=ar[N-1]+br[N-1];
// cout << "tag=" << tag << '\n';
// for(int i=0;i<N;i++) cout << ar[i] << " "; cout << '\n';
// for(int i=0;i<N;i++) cout << br[i] << " "; cout << '\n';
cout << sum-tag << '\n';
}
return (0-0);
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 7696kb
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:
5 1 3 499473410 36
result:
wrong answer 3rd numbers differ - expected: '2', found: '3'