Submission #387816

#TimeUsernameProblemLanguageResultExecution timeMemory
387816KrisjanisPRoses (BOI20_roses)C++14
100 / 100
3 ms300 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const ll lim = 1e16; ll N, A, B, C, D; int main(){ cin>>N>>A>>B>>C>>D; if((double)D/(double)C<(double)B/(double)A){ swap(A, C); swap(B, D); } ll res = ((N+A-1)/A)*B; ll n = A/__gcd(A,C);//LCM/C - maximum number of times that second buquet can appear for(int i=1;i<=n;i++){ ll new_res = 0; new_res += i*D; ll left = N-(i*C); if(left>0) new_res += ((left+A-1)/A)*B; res = min(res, new_res); } cout<<res<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...