# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1184526 | 12345678 | Roses (BOI20_roses) | C++20 | 0 ms | 332 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n, a, b, c, d, res, ans=1e18;
ll divide(ll x, ll y)
{
if ((x%y)==0) return x/y;
return x/y+1;
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>a>>b>>c>>d;
ll cnt=n/(a*c);
n-=cnt*(a*c);
res=min(b*c, a*d)*cnt;
for (int i=0; i*a<=n; i++) ans=min(ans, res+b*i+d*divide(n-i*a, c));
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |