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 <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <numeric>
#include <stack>
#include <cstring>
#include <bitset>
#include <climits>
#include <valarray>
#include <list>
#define int long long
#define inf 1000000000
#define endl '\n'
#define mod 1000000007
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
if (a*b > c*d){
swap(a, c);
swap(b, d);
}
int mn = inf;
for (int i = 0; i <= n-1/a+1; i++){
int sec = n - (i*a);
int fir = 0;
if (sec > 0){
fir = (sec-1)/c+1;
}
mn = min(mn, (fir*d)+(i*b));
}
cout << mn << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |