#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#define maxn 100005
using namespace std;
typedef long long ll;
int main(){
// freopen("in.txt", "r", stdin);
ll d, a, b, k, t, ans = 0;
scanf("%I64d%I64d%I64d%I64d%I64d", &d, &k, &a, &b, &t);
if(k >= d){
printf("%I64d\n", a * d);
return 0;
}
ans = a * k;
ll t1 = a * k + t;
ll t2 = b * k;
t1 = min(t1, t2);
d -= k;
ans += d / k * t1;
d %= k;
t1 = t + d * a;
t2 = d * b;
t1 = min(t1, t2);
ans += t1;
printf("%I64d\n", ans);
return 0;
}
Educational Codeforces Round 15 D. Road to Post Office
最新推荐文章于 2019-10-19 20:17:40 发布