QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#759999#8057. Best Carry Player 4RykonyWA 50ms3568kbC++201016b2024-11-18 13:58:292024-11-18 13:58:33

Judging History

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

  • [2024-11-18 13:58:33]
  • 评测
  • 测评结果:WA
  • 用时:50ms
  • 内存:3568kb
  • [2024-11-18 13:58:29]
  • 提交

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;
		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';
		}
	}
}

詳細信息

Test #1:

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

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: 50ms
memory: 3568kb

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:

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

result:

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