QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#735899#8057. Best Carry Player 4oqmsac#WA 52ms5768kbC++231.2kb2024-11-11 22:29:242024-11-11 22:29:24

Judging History

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

  • [2024-11-11 22:29:24]
  • 评测
  • 测评结果:WA
  • 用时:52ms
  • 内存:5768kb
  • [2024-11-11 22:29:24]
  • 提交

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,sumb=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];
            sumb+=b[i];
            if(b[i]) mb=i;
        }
        if(ma+mb<n)
        {
            cout<<0<<endl;continue;
        }
        ll rest=0,ans=0,used=0,sa=0;
        for(int i=1;i<n-1;i++)
        {
            ans+=min(a[i],b[n-i-1]);
            sa+=a[i];
            if(a[i]<b[n-i-1]&&n-i-1)
            {
                b[n-i-2]+=b[n-i-1]-a[i];
               if(sa!=suma||a[n-1]) rest=1;
            }
            if(a[i]>b[n-i-1]&&(b[n-1]||used)) rest=1;
            used+=min(a[i],b[n-i-1]);
        }
        if(!rest) ans--;
        cout<<min(ans+a[n-1]+b[n-1],max(suma,sumb))<<endl;
    }
    return 0;
}


详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 5700kb

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: 52ms
memory: 5768kb

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
3
3
3
2
0
0
1
1
3
0
3
0
0
0
0
0
0
0
4
0
4
1
0
2
3
3
1
5
0
0
2
0
0
1
1
0
0
3
5
3
2
2
2
0
1
2
2
2
0
3
0
2
1
1
0
1
0
4
0
0
2
2
0
3
3
0
2
0
1
0
0
1
1
2
0
3
4
0
2
5
0
2
1
0
0
0
3
2
3
0
2
0
4
3
3
0
2
2
0
1
3
1
1
0
0
0
1
0
3
2
2
0
2
1
1
0
2
0
0
2
4
1
3
3
2
2
2
0
2
0
0
2
3
1
3
1
0
2
2
3
0
1
2
0
1
1
...

result:

wrong answer 121st numbers differ - expected: '1', found: '2'