Submission #6115

# Submission time Handle Problem Language Result Execution time Memory
6115 2014-06-20T01:18:24 Z hongjun7 쌍둥이 독수리 (GA7_twineagles) C++
0 / 100
432 ms 32768 KB
#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
1 Memory limit exceeded 432 ms 32768 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 424 ms 32768 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 420 ms 32768 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 416 ms 32768 KB Memory limit exceeded
2 Halted 0 ms 0 KB -