QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#630726 | #7781. Sheep Eat Wolves | CCF | WA | 0ms | 3716kb | C++14 | 877b | 2024-10-11 20:09:13 | 2024-10-11 20:09:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define fs first
#define sc second
#define pb push_back
#define SZ(X) (int)((X).size())
#define lb(i) ((i)&-(i))
#define cl(i) memset(i,0,sizeof(i))
const int N=6.1e3;
int main(){
int x,y,p,q,cnt=0;
cin>>x>>y>>p>>q;
if(p>=x)return puts("1"),0;
int a=x,b=y;
int nw=0;
if(y-x>q){
while(y-x>q&&nw<p)y--,nw++;
cnt++;
}//cerr<<"?"<<x<<" "<<y<<"\n";
if(y-x>q)return puts("-1"),0;
while(x>0){
int _x=x,_y=y,flag=0;
if(nw)flag=1;
while(y-x<q&&nw<p){
x--,nw++;
}
while(nw<=p-2)x--,y--,nw+=2;
if(nw==p-1&&((b-y)-(a-x)<q))y--,nw++;
cnt++,nw=0;
if(x==_x&&y==_y&&!flag)return puts("-1"),0;
}
cout<<cnt<<"\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
2 5 1 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
1 1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3628kb
input:
3 3 1 1
output:
5
result:
wrong answer 1st numbers differ - expected: '7', found: '5'