Submission #395154

#TimeUsernameProblemLanguageResultExecution timeMemory
395154kaplanbarRoses (BOI20_roses)C++14
100 / 100
4 ms320 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n; ll a, b, c, d; cin >> n >> a >> b >> c >> d; ll ans = 1e18; auto calculate1 = [&](ll c1) -> ll { ll c2 = max(0ll, n - c1 * a + c - 1) / c; return c1 * b + c2 * d; }; auto calculate2 = [&](ll c1) -> ll { ll c2 = max(0ll, n - c1 * c + a - 1) / a; return c1 * d + c2 * b; }; for(int i = 0; i <= min(ll(1e5), n); i++) { ans = min(ans, calculate1(i)); ans = min(ans, calculate2(i)); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...