QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#709243#8057. Best Carry Player 4frankly6WA 1ms9772kbC++171.5kb2024-11-04 13:15:152024-11-04 13:15:15

Judging History

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

  • [2024-11-04 13:15:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:9772kb
  • [2024-11-04 13:15:15]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define int long long
using namespace std;
const int MX=500050;
const int inf=1e15;

int T, N;
int ar[MX], br[MX], a[MX], b[MX];
bool vis[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();
        int sa=0, sb=0;
        for(int i=0;i<N;i++) a[i]=ar[i]=read(), sa+=ar[i];
        for(int i=0;i<N;i++) b[i]=br[i]=read(), sb+=br[i];
        for(int i=0;i<N;i++) vis[i]=0;
        if(sa<sb) ar[0]+=sb-sa;
        else br[0]+=sa-sb;
        sa=sb=max(sa,sb);
        int ans=0, tag=1;
        for(int i=0,j=N-1;i<N;i++)
        {
            int now=0;
            while(ar[i]>now&&j>=N-i-1) 
            {
                if(j>N-i-1&&br[j]) tag=0;
                int d=ar[i]-now;
                int del=min(d,br[j]);
                if(del) vis[i]=1;
                br[j]-=del; ar[i]-=del; now+=del;
                if(!br[j]) j--;
            }
            ans+=now;
        }
        // for(int i=1;i<N;i++) if(ar[i]||br[i]) tag=0;
        for(int i=0,now=0;i<N;i++)
        {
            if(ar[i]&&now) tag=0;
            if(vis[i]) now=1;
        }
        if(!ans) cout << "0\n";
        else cout << ans-tag << '\n';
    }
    return (0-0);
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 9772kb

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
24

result:

wrong answer 5th numbers differ - expected: '29', found: '24'