QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#735878#8057. Best Carry Player 4oqmsac#WA 63ms5720kbC++231.1kb2024-11-11 22:16:592024-11-11 22:16:59

Judging History

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

  • [2024-11-11 22:16:59]
  • 评测
  • 测评结果:WA
  • 用时:63ms
  • 内存:5720kb
  • [2024-11-11 22:16:59]
  • 提交

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


详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5716kb

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: 63ms
memory: 5720kb

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
0
3
0
3
1
1
0
0
0
1
0
4
1
4
0
0
2
3
3
1
5
0
0
2
0
1
1
0
0
1
3
5
3
2
2
0
0
0
2
3
2
0
3
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 12th numbers differ - expected: '1', found: '0'