ZJU 3464 解题报告

Rugby Football

Time Limit: 2 Seconds Memory Limit: 65536 KB

CM is a member of Rugby football club of ZJU. He loves to play the game. Every Friday afternoon there is a club training of skills. CM wants to make it more effective.

In the training, N club members including CM stand at staring line in a row. The maximum velocity of the i-th player is Vi. The distance between the line and touchdown zone is L. The goal is to send the ball to touchdown zone. They can pass the ball to others but forward passing is illegal. If someone reaches touchdown zone with ball, the team scores and it will be an effective training.

This picture illustrate the rule of passing ball.

But the way to scoring is not easy because of crazy opponents. Any player with the ball cannot rush more than T seconds or he will be tackled. And he cannot be passed again because he will be very tired after sprinting; even have not for T seconds enough. At the beginning CM can choose who takes the ball first. Now CM wants to know whether they can score and how fast they can.


The first line is an integer RP. Then RP cases follow. There are no more than 20 cases.

For each case, there are two lines. The first line contains three integers N, T, L (1 ≤ N,T ≤ 10000, 1 ≤ L ≤ 109). The second line has N integers indicating V1, V2 ... Vn. (1 ≤ Vi ≤ 10000)


A single line with a float number S and correct to two decimal places. It means the total seconds they need to score. If they cannot score, output -1.

Sample Input

3 4 20
2 3 4
1 1 10

Output for Sample Input


Author: HUANG, Minzhi

Contest: ZOJ Monthly, January 2011




using namespace std;
bool cmp(int a, int b)
  return a > b;
int main()
  int rp;
  cin >> rp;
  int n, t, l;
      cin >> n >> t >> l;
      int v[n];
      for(int i = 0; i < n; ++i)
          scanf("%d", &v[i]);
      sort(v, v + n, cmp);
      for(int i = 0; i < n; ++i)
          if(l <= v[i] * t)
              printf("%.2lf\n", t * i + 1.0 * l / v[i]);
              l = 0;
              l -= v[i] * t;
      if(l) puts("-1");
  return 0;
» 本博客采用署名 2.5 中国大陆许可协议进行许可,本文版权归作者所有,欢迎转载,但必须在明显位置给出原文连接。

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>