Submission #6025

#TimeUsernameProblemLanguageResultExecution timeMemory
6025ainta쌍둥이 독수리 (GA7_twineagles)C++98
91 / 100
0 ms4260 KiB
#pragma warning(disable:4996) #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[500][500]; int Q[250100][2]; bool v[500][500]; int LH, S, D, L, B, h, t; void Ins(int x, int y, int d){ if (x > 500 || y > 500)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); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...