QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#760020#8057. Best Carry Player 4RykonyWA 0ms3552kbC++201.0kb2024-11-18 14:07:482024-11-18 14:07:50

Judging History

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

  • [2024-11-18 14:07:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-11-18 14:07:48]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using LL=long long;

int main()
{
	cin.tie(0)->sync_with_stdio(false);
	int _=1;
	cin>>_;
	while (_--){
		int n;
		cin>>n;
		vector <LL> a(n+10,0),b(n+10,0);
		LL fin=0;
		for (int i=0;i<n;i++) cin>>a[i],fin+=a[i];
		for (int i=0;i<n;i++) cin>>b[i],fin-=b[i];
		if (fin>0) b[0]+=fin;
		else a[0]-=fin;
		vector <LL> c=a,d=b;
		if (fin>0) swap(c,d);
		LL ans=0,r=n-1,bg=0;
		for (int i=0;i<n;i++){
			while (r>=0 and r+i>=n-1 and c[i]){
				if (d[r]>c[i]){
					if (r+i>=n) bg=1;
					ans+=c[i];
					d[r]-=c[i];
					c[i]=0;
				}
				else{
					if (r+i>=n and d[r]) bg=1;
					ans+=d[r];
					c[i]-=d[r];
					d[r]=0;
					r--;
				}
			}
		}
		if (bg) cout<<ans<<'\n';
		else{
			int id=0;
			for (int i=n-1;i>=1;i--){
				if (a[i]){
					id=i;
					break;
				}
			}
			bool fd=0;
			for (int i=n-1;i>=0;i--){
				if (id+i>=n and b[i]){
					fd=1;
					break;
				}
			}
			if (fd) cout<<ans-1<<'\n';
			else cout<<0<<'\n';
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3552kb

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
0
2
467900
29

result:

wrong answer 2nd numbers differ - expected: '1', found: '0'