이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
#define mp make_pair
ll attack, strength[2], heal[2], res;
map < pair <ll, ll>, ll > d;
queue <ll> Qx, Qy, Qr;
int main() {
scanf("%lld%lld%lld%lld%lld",&attack,&strength[0],&strength[1],&heal[0],&heal[1]);
d[mp(strength[0], strength[1])] = res;
Qx.push(strength[0]);
Qy.push(strength[1]);
Qr.push(res);
ll x, y, r, a, b;
while (!Qx.empty()) {
x = Qx.front(); Qx.pop();
y = Qy.front(); Qy.pop();
r = Qr.front(); Qr.pop();
if (x == 0 && y == 0) break;
a = x-2*attack;
if (a <= 0) a = 0;
else a += heal[0];
if (d[mp(a,y)] == 0) {
d[mp(a,y)] = r+1;
Qx.push(a); Qy.push(y); Qr.push(r+1);
}
b = y-2*attack;
if (b <= 0) b = 0;
else b += heal[1];
if (d[mp(x,b)] == 0) {
d[mp(x,b)] = r+1;
Qx.push(x); Qy.push(b); Qr.push(r+1);
}
a = x-attack;
if (a <= 0) a = 0;
else a += heal[0];
b = y-attack;
if (b <= 0) b = 0;
else b += heal[1];
if (d[mp(a,b)] == 0) {
d[mp(a,b)] = r+1;
Qx.push(a); Qy.push(b); Qr.push(r+1);
}
}
printf("%lld",d[mp(0,0)]);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |