이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
int n, a, b, c, d;
cin >> n >> a >> b >> c >> d;
int c1, c2, c3, c4;
c1 = ((n - 1) / a + 1) * b;
c3 = ((n - 1) / c + 1) * d;
c2 = (n / a) * b + (((n % a) - 1) / c + 1) * d;
//if ((n - c) % a == 0 && n-c > 0)
// c2 = d + ((n - c) / a) * b;
if((n-c)/a < n/a){
c2 = d + ((n - c-1) / a+1) * b;
}
c4 = (n / c) * d + (((n % c) - 1) / a + 1) * b;
//if ((n - a) % c == 0 && n-a > 0)
// c4 = b + ((n - a) / c) * d;
if((n-a)/c < n/c){
c4 = b + ((n - a-1) / c+1) * d;
}
cout << min(c1, min(c2, min(c3, c4))) << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |