Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- long long h, b, t, w[3], dp[2000000];
- int main() {
- while (cin >> h >> b >> t) {
- for (int i = 0; i < 3; i++)
- cin >> w[i];
- for (int ch = 0; ch <= h; ch++)
- dp[ch] = 0;
- long long res = 0;
- for (int ch = 0; ch <= h; ch++) {
- res = max(res, dp[ch]);
- for (int i = 0; i < 3; i++) {
- if (ch + w[i] > t)
- continue;
- long long nh = ch + w[i];
- long long k = (nh * t + (h - nh) * b) / (h * w[i]);
- dp[nh] = max(dp[nh], dp[ch] + w[i] * w[i] * w[i] * k * k);
- }
- }
- cout << res << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement