Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdio>
- #include<algorithm>
- using namespace std;
- int n, L, S, v[20000], x[20000], l[20000], sum[20000], s;
- double t[20000];
- int main()
- {
- while(1)
- {
- scanf("%d%d%d%d", &n, &L, &S, &v[0]);
- if (n == 0)
- break;
- for (int i = 1; i <= n; i++)
- {
- scanf("%d%d%d", &x[i], &l[i], &v[i]);
- sum[i] = sum[i - 1] + L + l[i];
- }
- for (int i = n; i >= 0; i--)
- {
- s = S + sum[i];
- if (s <= x[i])
- {
- t[i] = 0;
- continue;
- }
- if (i == n)
- t[i] = (double) (s - x[i]) / (double) v[i];
- else
- t[i] = max((double)(s - x[i]) / (double) v[i], t[i + 1]);
- }
- printf("%.20lf\n", t[0]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement