Submission #1269910

#TimeUsernameProblemLanguageResultExecution timeMemory
1269910jovid쌍둥이 독수리 (GA7_twineagles)C++20
23 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> const int INF = 1LL << 62; int count(int x, int y, int z) { if (y <= 0) { return 0; } if (x >= y) { return 1; } if (x <= z) { return INF; } int lo = 0; int hi = 200000000LL; while (lo + 1 < hi) { int mid = (lo + hi) / 2; bool success = ((y - mid * x + mid * z - z) <= 0); if (success) { hi = mid; } else { lo = mid; } } return hi; } int32_t main() { cin.tie(0)->sync_with_stdio(0); int atk, xl, yl, xh, yh; cin >> atk >> xl >> yl >> xh >> yh; if (xl == 0 && yl == 0) { cout << 0; return 0; } int ans = INF; for (int i = 0; i < 2; ++i) { int d1 = count(2 * atk, xl, xh); int x_last_life = xl - (d1 - 1) * (2 * atk) + (d1 - 1) * xh; int d2; if (x_last_life > atk) { d2 = count(2 * atk, yl + d1 * yh, yh); } else { int y_post = yl + (d1 - 1) * yh - atk; if (y_post <= 0) { d2 = 0; } else { d2 = count(2 * atk, y_post + yh, yh); } } ans = min(ans, d1 + d2); swap(xl, yl); swap(xh, yh); } cout << ans; }
#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...