#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll A,B,C,D,N;
cin>>N>>A>>B>>C>>D;
if(B*D>A*C){
swap(A,C);
swap(B,D);
}
ll q=N/A;
ll sol=q*B;
ll p=(N%A)/C;
if(p*C<N%A)p++;
if(p*D<B)sol+=p*D;
else sol+=B;
cout<<sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |