This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |