QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#333771#8057. Best Carry Player 4ucup-team3160#WA 142ms3592kbC++141.5kb2024-02-20 15:16:412024-02-20 15:16:42

Judging History

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

  • [2024-02-20 15:16:42]
  • 评测
  • 测评结果:WA
  • 用时:142ms
  • 内存:3592kb
  • [2024-02-20 15:16:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
void qrun(){
	int m;
	cin>>m;
	long long *p,*q;
	p=new long long[m+1];
	q=new long long[m+1];
	for(int i=1;i<=m;i++){
		cin>>p[i-1];
	}
	for(int i=1;i<=m;i++){
		cin>>q[i-1];
	}
	p[0]+=1e10;
	long long cnt=0,sum=0;
	bool ten=false,o=false,ob=false,obb=false;
	int specp=0;
	for(int i=0;i<m;i++){
		if(p[i]>0){
			specp++;
		}
	}
	int specq=0;
	for(int i=0;i<m;i++){
		if(p[i]>0){
			specp++;
		}
	}
	bool spec=false;
	if(specp<=1&&specq<=1){
		spec=true;
	}
	for(int i=0;i<m;i++){
		sum+=q[m-1-i];
		if(i==m-1){
			sum=1e10;
		}
		//cout<<"进行到第"<<i<<"轮,目前sum:"<<sum<<"cnt:"<<cnt<<"o:"<<o<<"ob:"<<ob<<"obb:"<<obb<<"ten:"<<ten<<endl;
		if(sum>0&&p[i]>0){
			ob=true;
		}
		if(p[i]>sum&&obb){
			ten=true;
		}
		if(p[i]>=sum){
			cnt+=sum;
			sum=0;
		}
		else{
			if(o){
				cnt+=p[i];
				sum-=p[i];
				if(p[i]!=0){
					ten=true;
				}
			}
			else{
				o=true;//大数第一次溢出 
				cnt+=p[i];
				sum-=p[i];
			}
			
		}
		if(ob){
			obb=true;
		}
		//cout<<"进行完第"<<i<<"轮,目前sum:"<<sum<<"cnt:"<<cnt<<"o:"<<o<<"ob:"<<ob<<"obb:"<<obb<<"ten:"<<ten<<endl;
	}
	if(ten){
		//cout<<"输出:"<<cnt<<endl;
		cout<<cnt<<endl;
	}
	else{
		if(spec){
		//	cout<<"输出"<<"0\n";
			cout<<"0\n";
		}
		else{
		//	cout<<"输出"<<cnt-1<<endl;
			cout<<(cnt>0 ? cnt-1 : cnt)<<endl;
		}
	}
	delete[] p;
	delete[] q;
	return;
}
int main(){
	int t;
	cin>>t;
	for(int i=1;i<=t;i++){
		qrun();
	}
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 142ms
memory: 3592kb

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

result:

wrong answer 5th numbers differ - expected: '3', found: '4'