QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623912 | #7781. Sheep Eat Wolves | MEshooter# | WA | 0ms | 3892kb | C++20 | 790b | 2024-10-09 14:21:27 | 2024-10-09 14:21:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int SIZE = 2e5+10;
int x,y,p,q,xl,xr,yl,yr;
int main(){
scanf("%lld%lld%lld%lld",&x,&y,&p,&q);
int ans=0;
xl=x,xr=0,yl=y,yr=0;
while(xl)
{
if(xl<=p){ans++;break;}
else if(yl-q>xl-p)
{
ans++;
int k=yl-xl-q;
if(k>p){printf("-1");return 0;}
int wolf =(k+p+1)/2;
yl-=wolf;
yr=wolf;
xl-=p-wolf;
xr+=p-wolf;
}
else
{
ans++;
xl-=p;
xr+=p;
}
ans++;
if(yr-xr-q>0&&xr>0)
{
yl+=yr-xr-q;
yr-=yr-xr-q;
}
}
printf("%lld",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3892kb
input:
4 4 3 1
output:
0
result:
wrong answer 1st numbers differ - expected: '3', found: '0'