Submission #642276

#TimeUsernameProblemLanguageResultExecution timeMemory
642276KenparRoses (BOI20_roses)C++17
0 / 100
0 ms300 KiB
//Segment Tree Degil Bu What #include "bits/stdc++.h" using namespace std; #define ll long long const ll MOD = 1e9+7; const ll MAX = 2e5+1; void solve(){ ll n,a,b,c,d; cin>>n>>a>>b>>c>>d; ll ans1 = 0, ans2 = 0; long double first = ((long double)b)/a, second = ((long double)d)/c; if(first > second){ ans1 = (n / c) * d; n-=((n / c) * c ); if(n == 0){ cout<<ans1; return; } ans2 = ans1; ans1 += d; ans2 += (n / a) * b; n-= (n / a) * a; if(n != 0){ ans2+= b; } cout << min(ans1,ans2); }else{ ans1 = (n / a) * b; n-=((n / a) * b ); if(n == 0){ cout<<ans1; return; } ans2 = ans1; ans1 += b; ans2 += (n / c) * d; n-= (n / c) * c; if(n != 0){ ans2+= d; } cout << min(ans1,ans2); } } int main() { int t = 1; //cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...