이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
long double nn = n, aa = a, cc = c;
int mn = inf;
for (int i = 0; i <= ceil(nn/aa); i++){
int sec = n - (i*aa);
int fir = 0;
if (sec > 0){
long double secc = sec;
fir = ceil(secc/cc);
}
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... |