답안 #6027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
6027 2014-06-15T17:52:10 Z ainta 쌍둥이 독수리 (GA7_twineagles) C++
100 / 100
0 ms 1216 KB
#include<stdio.h>
long long R, R2, tp;
void Do(long long LH, long long S, long long D, long long L, long long B)
{
	R = 0;
	if (S > LH * 2)R += (S - LH * 2) / (2 * LH - L);
	S -= R * (2 * LH - L);
	if (S > LH * 2){
		R++;
		S -= (2 * LH - L);
	}
	if (S > LH){
		R++;
		D += R * B;
	}
	else{
		D += R*B;
		D -= LH;
		R++;
		if (D <= 0)return;
		D += B;
	}
	if (D > LH * 2){
		tp = (D - LH * 2) / (2 * LH - B);
		R += tp;
		D -= tp * (2 * LH - B);
	}
	if (D > LH * 2)R += 2;
	else R++;
	return;
}
int DP[100][100];
int Q[10100][2];
bool v[100][100];
int LH, S, D, L, B, h, t;
void Ins(int x, int y, int d){
	if (x >= 100 || y >= 100)return;
	if (v[x][y])return;
	DP[x][y] = d;
	Q[++t][0] = x;
	Q[t][1] = y;
	v[x][y] = true;
}
void Do2(int x, int y){
	int d = DP[x][y] + 1, x1 = x, y1 = y;
	if (x)x1 = x + L;
	if (y)y1 = y + B;
	if (x <= 2 * LH)Ins(0, y1, d);
	else Ins(x - 2 * LH + L, y1, d);
	if (y <= 2 * LH)Ins(x1, 0, d);
	else Ins(x1, y - 2 * LH + B, d);
	x1 = x - LH, y1 = y - LH;
	if (x1 <= 0)x1 = 0;
	else x1 += L;
	if (y1 <= 0)y1 = 0;
	else y1 += B;
	Ins(x1, y1, d);
}
void Do3()
{
	int i, x, y;
	Ins(S, D, 0);
	while (h < t){
		++h;
		x = Q[h][0], y = Q[h][1];
		if (!x && !y)break;
		Do2(x, y);
	}
	printf("%d\n", DP[0][0]);
}
int main()
{
	scanf("%d%d%d%d%d", &LH, &S, &D, &L, &B);
	if (LH <= 10 && S <= 10 && D <= 10 && L <= 10 && B <= 10){
		Do3();
		return 0;
	}
	Do(LH, S, D, L, B);
	R2 = R;
	Do(LH, D, S, B, L);
	printf("%lld\n", R < R2 ? R : R2);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1216 KB Output is correct
2 Correct 0 ms 1216 KB Output is correct
3 Correct 0 ms 1216 KB Output is correct
4 Correct 0 ms 1216 KB Output is correct
5 Correct 0 ms 1216 KB Output is correct
6 Correct 0 ms 1216 KB Output is correct
7 Correct 0 ms 1216 KB Output is correct
8 Correct 0 ms 1216 KB Output is correct
9 Correct 0 ms 1216 KB Output is correct
10 Correct 0 ms 1216 KB Output is correct
11 Correct 0 ms 1216 KB Output is correct
12 Correct 0 ms 1216 KB Output is correct
13 Correct 0 ms 1216 KB Output is correct
14 Correct 0 ms 1216 KB Output is correct
15 Correct 0 ms 1216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1216 KB Output is correct
2 Correct 0 ms 1216 KB Output is correct
3 Correct 0 ms 1216 KB Output is correct
4 Correct 0 ms 1216 KB Output is correct
5 Correct 0 ms 1216 KB Output is correct
6 Correct 0 ms 1216 KB Output is correct
7 Correct 0 ms 1216 KB Output is correct
8 Correct 0 ms 1216 KB Output is correct
9 Correct 0 ms 1216 KB Output is correct
10 Correct 0 ms 1216 KB Output is correct
11 Correct 0 ms 1216 KB Output is correct
12 Correct 0 ms 1216 KB Output is correct
13 Correct 0 ms 1216 KB Output is correct
14 Correct 0 ms 1216 KB Output is correct
15 Correct 0 ms 1216 KB Output is correct
16 Correct 0 ms 1216 KB Output is correct
17 Correct 0 ms 1216 KB Output is correct
18 Correct 0 ms 1216 KB Output is correct
19 Correct 0 ms 1216 KB Output is correct
20 Correct 0 ms 1216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1216 KB Output is correct
2 Correct 0 ms 1216 KB Output is correct
3 Correct 0 ms 1216 KB Output is correct
4 Correct 0 ms 1216 KB Output is correct
5 Correct 0 ms 1216 KB Output is correct
6 Correct 0 ms 1216 KB Output is correct
7 Correct 0 ms 1216 KB Output is correct
8 Correct 0 ms 1216 KB Output is correct
9 Correct 0 ms 1216 KB Output is correct
10 Correct 0 ms 1216 KB Output is correct
11 Correct 0 ms 1216 KB Output is correct
12 Correct 0 ms 1216 KB Output is correct
13 Correct 0 ms 1216 KB Output is correct
14 Correct 0 ms 1216 KB Output is correct
15 Correct 0 ms 1216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1216 KB Output is correct
2 Correct 0 ms 1216 KB Output is correct
3 Correct 0 ms 1216 KB Output is correct
4 Correct 0 ms 1216 KB Output is correct
5 Correct 0 ms 1216 KB Output is correct
6 Correct 0 ms 1216 KB Output is correct
7 Correct 0 ms 1216 KB Output is correct
8 Correct 0 ms 1216 KB Output is correct
9 Correct 0 ms 1216 KB Output is correct
10 Correct 0 ms 1216 KB Output is correct
11 Correct 0 ms 1216 KB Output is correct
12 Correct 0 ms 1216 KB Output is correct
13 Correct 0 ms 1216 KB Output is correct
14 Correct 0 ms 1216 KB Output is correct
15 Correct 0 ms 1216 KB Output is correct
16 Correct 0 ms 1216 KB Output is correct
17 Correct 0 ms 1216 KB Output is correct
18 Correct 0 ms 1216 KB Output is correct
19 Correct 0 ms 1216 KB Output is correct
20 Correct 0 ms 1216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1216 KB Output is correct
2 Correct 0 ms 1216 KB Output is correct
3 Correct 0 ms 1216 KB Output is correct
4 Correct 0 ms 1216 KB Output is correct
5 Correct 0 ms 1216 KB Output is correct
6 Correct 0 ms 1216 KB Output is correct
7 Correct 0 ms 1216 KB Output is correct
8 Correct 0 ms 1216 KB Output is correct
9 Correct 0 ms 1216 KB Output is correct
10 Correct 0 ms 1216 KB Output is correct
11 Correct 0 ms 1216 KB Output is correct
12 Correct 0 ms 1216 KB Output is correct
13 Correct 0 ms 1216 KB Output is correct
14 Correct 0 ms 1216 KB Output is correct
15 Correct 0 ms 1216 KB Output is correct
16 Correct 0 ms 1216 KB Output is correct
17 Correct 0 ms 1216 KB Output is correct
18 Correct 0 ms 1216 KB Output is correct
19 Correct 0 ms 1216 KB Output is correct
20 Correct 0 ms 1216 KB Output is correct
21 Correct 0 ms 1216 KB Output is correct
22 Correct 0 ms 1216 KB Output is correct
23 Correct 0 ms 1216 KB Output is correct
24 Correct 0 ms 1216 KB Output is correct
25 Correct 0 ms 1216 KB Output is correct
26 Correct 0 ms 1216 KB Output is correct
27 Correct 0 ms 1216 KB Output is correct
28 Correct 0 ms 1216 KB Output is correct
29 Correct 0 ms 1216 KB Output is correct
30 Correct 0 ms 1216 KB Output is correct