Skip to content

Instantly share code, notes, and snippets.

@anakryiko
Created May 11, 2013 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anakryiko/5561673 to your computer and use it in GitHub Desktop.
Save anakryiko/5561673 to your computer and use it in GitHub Desktop.
Russian Code Cup 2013 Qualification 2, problem C
#include <cstdio>
#define FOR(i,f,n) for(int i=f; i<n; ++i)
int N, M, K, L, S, V;
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
while (true)
{
scanf("%d%d%d%d", &N, &L, &S, &V);
if (N == 0)
break;
double res = S / (0.0 + V);
int len = 0;
FOR(i,0,N)
{
int x, l, v;
scanf("%d%d%d", &x, &l, &v);
len += L + l;
double r = (S + len - x) / (v + 0.0);
res = max(res, r);
}
printf("%.9lf\n", res);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment