Guest User

Untitled

a guest
Jan 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. #define LL long long int
  6. LL n, h;
  7. LL a, b, c, d, e;
  8.  
  9. // 質素な食事の最低限の回数が求められる
  10. inline LL minCheapFood(double x){
  11. return ((n - x)*e - h - b*x) / (d + e) + 1;
  12. }
  13.  
  14. int main(){
  15. cin >> n >> h;
  16. cin >> a >> b >> c >> d >> e;
  17.  
  18. LL cost = 1e14;
  19. for (LL x = 0; x <= n; x++){
  20. LL y = max(0LL, minCheapFood(x));
  21. if (x + y <= n){
  22. cost = min(cost, (LL)(a*x + c*y));
  23. }
  24. }
  25. cout << cost << endl;
  26. }
Add Comment
Please, Sign In to add comment