제출 #1331163

#제출 시각아이디문제언어결과실행 시간메모리
1331163Zone_zoneeRoses (BOI20_roses)C++20
100 / 100
7 ms452 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll divide(ll a, ll b){
    if(a%b == 0) return a/b;
    return a/b+1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    ll res = 2e18;
    for (int i = 0; i <= 1000000; ++i) if (a*i <= n) res = min(res, b*i+divide(n-a*i, c)*d);
    for (int i = 0; i <= 1000000; ++i) if (c*i <= n) res = min(res, d*i+divide(n-c*i, a)*b);
    cout << res << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...