9
26
2015
2

hiho一下 第六十五周

又被水题虐智商

#include <cstdio>
#include <algorithm>
using namespace std;

int N;
struct Car
{
	int X, Y;
	double L;
	inline void Read()
	{
		scanf("%d%d%lf", &X, &Y, &L);
	}
} C[1003];
int p[1003], o[1003];
double Res[1003], t[1003];
inline bool cmp(int a, int b)
{
	return C[a].X > C[b].X;
}
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i ++) C[o[i] = i].Read(), p[i] = C[i].Y;
	sort(p + 1, p + N + 1), sort(o + 1, o + N + 1, cmp);
	for (int i = 1; i <= N; i ++)
	{
		int Cur = o[i], Pos = C[Cur].X;
		double T = 0;
		for (int j = 1; j <= N; j ++)
			if (p[j] >= Pos)
			{
				T += (double)(p[j] - Pos) / C[Cur].L;
				T = t[j] = max(t[j], T), Pos = p[j];
				if (Pos == C[Cur].Y)
				{
					Res[Cur] = T;
					break;
				}
			}
	}
	for (int i = 1; i <= N; i ++) printf("%.2lf\n", Res[i]);
	return 0;
}
Category: hihocoder | Tags: math

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com