Submission #1269869

#TimeUsernameProblemLanguageResultExecution timeMemory
1269869jovid쌍둥이 독수리 (GA7_twineagles)C++20
0 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> const int INF = 1LL << 63; int count(int x, int y, int z) { if (y <= 0) { return 0; } if (x <= z) { return INF; } if ((y - z) % (x - z) == 0) { return (y + z) / (x - z); } long double d = ((long double)(y - z) / (x - z)); return ceil(d); } int32_t main() { cin.tie(0)->sync_with_stdio(0); int atk, xl, yl, xh, yh; cin >> atk >> xl >> yl >> xh >> yh; int ans = 1LL << 60; for (int i = 0; i < 2; ++i) { // kill x int d1 = count(2 * atk, xl, xh); // d1일 뒤에는 무조건 죽음 즉, d1일에는 xl<= 0; // (d1-1)일의 x의 체력 int x_last_life = xl - (d1 - 1) * (2 * atk) + (d1 - 2) + xh; int d2; if (x_last_life > atk) { // 2마리 독수리가 합심해야 하는 경우 d2 = count(2 * atk, yl + d1 * yh, yh); } else { // 1마리만 때려도 되는 경우 d2 = count(2 * atk, yl - atk + (d1 - 1) * yh, yh); } // cout << d1 << ' ' << d2 << endl; 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...