QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#692910 | #7781. Sheep Eat Wolves | blhxzjr# | WA | 0ms | 3688kb | C++23 | 1.3kb | 2024-10-31 15:12:44 | 2024-10-31 15:12:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
signed main(){
int x,y,q,p;
cin >> x >> y >> p >> q;
int flag=1;
if(p>=x){
cout << 1;
return 0;
}
if(y>x+q){
int cs=0;
if(y>x+q+p){
cout << -1;
return 0;
}
else{
int qf=-1;
if(y!=x+q+p){
int duo=y-x-q;
int kong=p-duo;
int lang=(kong+1)/2+duo;
int yang=kong/2;
int zuolang=y-lang,zuoyang=x-yang;
lang=lang-min(lang,yang+q);
yang=0;
cs+=2;
int cw=p-lang;
if(zuolang==zuoyang+q){
//先狼
if(zuoyang>p){
cs+=((zuoyang-p)*2+cw-1)/cw*2+1;
}
else cs++;
}
else{
//先羊
if(zuoyang>p){
cs+=((zuoyang-p)*2-1+cw-1)/cw*2+1;
}
else cs++;
}
// cout << zuolang << " " << zuoyang << " " << p << " " << cw << "\n";
}
if(2*(x-p)>=p-q) qf=5;
if(qf!=-1 && cs!=0){
cout << min(qf,cs);
}
else if(qf!=-1){
cout << qf;
}
else if(cs!=0){
cout << cs;
}
else cout << -1;
}
}
else{
if(x+q>=y){
//一次运走
if(p>=x){
cout << 1;
return 0;
}
//一次运不走
else{
int duo=x+q-y;
int zs=(y-duo)*2+duo;
cout << (zs+p-1)/p;
return 0;
}
}
else flag=0;
}
if(!flag) cout << -1;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3496kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
2 5 1 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3632kb
input:
3 3 1 1
output:
5
result:
wrong answer 1st numbers differ - expected: '7', found: '5'