Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. long long h, b, t, w[3], dp[2000000];
  6.  
  7. int main() {
  8. while (cin >> h >> b >> t) {
  9. for (int i = 0; i < 3; i++)
  10. cin >> w[i];
  11. for (int ch = 0; ch <= h; ch++)
  12. dp[ch] = 0;
  13. long long res = 0;
  14. for (int ch = 0; ch <= h; ch++) {
  15. res = max(res, dp[ch]);
  16. for (int i = 0; i < 3; i++) {
  17. if (ch + w[i] > t)
  18. continue;
  19. long long nh = ch + w[i];
  20. long long k = (nh * t + (h - nh) * b) / (h * w[i]);
  21. dp[nh] = max(dp[nh], dp[ch] + w[i] * w[i] * w[i] * k * k);
  22. }
  23. }
  24. cout << res << "\n";
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement