| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 636982 | tvladm2009 | Roses (BOI20_roses) | C++14 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#define int long long
using namespace std;
int n, a, b, c, d;
int gcd(int a, int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
signed main() {
cin >> n >> a >> b >> c >> d;
if (b * c > d * a) {
swap(a, c);
swap(b, d);
}
int answer = (n + a - 1) / a * b;
int aux = a / gcd(a, c);
for (int i = 1; i <= aux - 1; i++) {
int cost = i * d;
if (n - c * i > 0) {
cost += (n - c * i + a - 1) / a * b;
}
answer = min(answer, cost);
}
cout << answer;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
