Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <algorithm>
- #include <string>
- #include <cstring>
- #include <cmath>
- using namespace std;
- #define y1 Y1
- typedef long long LL;
- int main() {
- LL t1, t2, x1, x2, t0, ans1, ans2, opt;
- while (cin >> t1 >> t2 >> x1 >> x2 >> t0) {
- opt = LL(1e18);
- for (int y2 = 0; y2 <= x2; y2++) {
- LL sum = y2 * (t2 - t0);
- int y1;
- if (t0 != t1)
- y1 = sum / (t0 - t1);
- else
- y1 = x1;
- if (y1 > x1) y1 = x1;
- sum += y1 * (t1 - t0);
- if ( (sum * (ans1 + ans2) < opt * (y1 + y2) || (sum * (ans1 + ans2) == opt * (y1 + y2) && y1 + y2 > ans1 + ans2)) && y1 + y2) {
- opt = sum;
- ans1 = y1;
- ans2 = y2;
- }
- }
- cout << ans1 << " " << ans2 << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement