QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#796183#7781. Sheep Eat WolvesUESTC_DebugSimulator#WA 0ms3700kbC++17629b2024-12-01 13:53:232024-12-01 13:53:23

Judging History

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

  • [2024-12-01 13:53:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3700kb
  • [2024-12-01 13:53:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x,y,p,q;
	cin>>x>>y>>p>>q;
	int lx=x,ly=y,rx=0,ry=0;
	int fl=0;
	for(int i=1;i<=1000;i++){
		int bx=0,by=0,r=p;
		if(lx<=p){
			cout<<2*i-1<<"\n";
			break;
		}
		by=max(0,ly-lx-q);
		r-=by;
		if(r<0){
			cout<<"-1\n";
			break;
		}
		bx=r/2;
		by+=(r+1)/2;
		lx-=bx;
		ly-=by;
		rx+=bx;
		ry+=by;
		if(bx==0)fl++;
		if(fl>=5){
			cout<<"-1\n";
			break;
		}
		if(rx){
			by=max(0,ry-rx-q);
			if(by>p){
				cout<<"-1\n";
				break;
			}
			ry-=by;
			ly+=by;
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 4 3 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

3 5 2 0

output:

5

result:

ok 1 number(s): "5"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

2 5 1 1

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

1 1 1 0

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3640kb

input:

3 3 1 1

output:

-1

result:

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