QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#735873 | #8057. Best Carry Player 4 | oqmsac# | WA | 51ms | 5644kb | C++23 | 1.1kb | 2024-11-11 22:15:02 | 2024-11-11 22:15:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
#define M 998244353
#define ll long long
#define pii pair<ll,ll>
ll a[N],b[N];
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
ll T;
cin>>T;
while(T--)
{
ll n,mb=0,ma=0,suma=0;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
suma+=a[i];
if(a[i]) ma=i;
}
for(int i=0;i<n;i++)
{
cin>>b[i];
if(a[i]) mb=i;
}
if(ma+mb<n)
{
cout<<0<<endl;continue;
}
ll rest=0,ans=0,used=0;
suma-=a[0]+a[n-1];
for(int i=1;i<n-1;i++)
{
ans+=min(a[i],b[n-i-1]);
suma-=a[i];
if(a[i]<b[n-i-1]&&n-i-1)
{
b[n-i-2]+=b[n-i-1]-a[i];
// rest=1;
}
if(a[i]!=b[n-i-1]) rest=1;
// used+=a[i];
}
if(!rest) ans--;
cout<<ans+a[n-1]+b[n-1]<<endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5596kb
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 2 467900 29
result:
ok 5 number(s): "5 1 2 467900 29"
Test #2:
score: -100
Wrong Answer
time: 51ms
memory: 5644kb
input:
100000 5 0 1 1 1 1 0 0 1 0 0 5 0 0 0 0 0 1 1 1 0 0 5 0 0 2 1 1 0 2 1 0 1 5 0 0 0 0 0 1 2 1 0 0 5 0 1 0 1 1 0 0 1 1 1 5 2 0 0 0 1 1 0 0 0 3 5 2 0 0 1 1 0 2 1 1 1 5 0 0 0 0 2 0 0 0 0 1 5 0 0 0 0 0 0 1 1 0 0 5 4 0 0 0 0 0 0 0 1 0 5 0 0 0 0 1 2 1 1 0 0 5 0 2 3 0 0 0 0 0 1 0 5 1 1 1 0 1 1 0 1 0 1 5 0 0 0...
output:
2 0 4 0 4 3 3 2 0 0 1 0 3 0 3 1 1 0 0 0 1 0 4 1 4 0 0 2 4 3 1 5 0 0 2 0 1 1 0 0 1 3 5 3 2 2 0 0 0 2 3 2 0 4 1 2 1 1 0 1 0 4 2 2 2 2 0 3 3 0 2 0 1 0 0 2 1 2 0 3 4 0 2 5 0 2 1 1 1 0 3 2 3 0 2 0 4 3 3 0 2 2 0 1 3 0 0 0 1 0 1 0 3 2 2 0 2 0 1 0 2 0 0 0 4 1 3 3 2 2 2 0 2 0 0 2 3 1 3 0 0 0 2 3 0 1 0 0 0 1 ...
result:
wrong answer 5th numbers differ - expected: '3', found: '4'