# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
300487 | bacegen4o | Roses (BOI20_roses) | C11 | 2 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize "-O3"
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<assert.h>
#include<stdbool.h>
#include<limits.h>
#define swap(a,b) do{ __typeof(a) tp; tp=a; a=b; b=tp; }while(0)
typedef long long ll;
static inline ll min(ll a, ll b){return a<b?a:b;}
ll gcd(ll a, ll b){
ll c = a % b;
while(c > 0){
a = b;
b = c;
c = a % b;
}
return b;
}
int main(){
ll A, B, C, D, N;
scanf("%lld %lld %lld %lld %lld", &N, &A, &B, &C, &D);
if(B*C > D*A){
swap(A, C);
swap(B, D);
}
ll ans = (N + A-1)/A*B;
ll n = A/gcd(A, C);
for(ll i=1; i<n; i++){
ll t = i*D;
if(N-C*i>0)
t+= (N - C*i + A-1)/A * B;
ans = min(ans, t);
}
printf("%lld\n", ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |