#P16515. [GKS 2015 #D] gBalloon

    ID: 16492 Type: RemoteJudge 1000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>2015二分Google Kick Start

[GKS 2015 #D] gBalloon

题目描述

The G tech company has deployed many balloons. Sometimes, they need to be collected for maintenance at the company's tower, which is located at horizontal position 00. Each balloon is currently at horizontal position PiP_i and height HiH_i.

G engineers can move a balloon up and down by sending radio signals to tell it to drop ballast or let out air. But they can't move the balloon horizontally; they have to rely on existing winds to do that.

There are MM different heights where the balloons could be. The winds at different heights may blow in different directions and at different velocities. Specifically, at height jj, the wind has velocity VjV_j, with positive velocities meaning that the wind blows left to right, and negative velocities meaning that the wind blows right to left. A balloon at position PP at a height with wind velocity VV will be at position P+VP+V after one time unit, P+2VP+2V after two time units, etc. If a balloon touches the tower, it is immediately collected.

It costs HoriginalHnew| H_{\text{original}} - H_{\text{new}} | points of energy to move one balloon between two different heights. (This transfer takes no time.) You have QQ points of energy to spend, although you do not need to spend all of it. What is the least amount of time it will take to collect all the balloons, if you spend energy optimally?

输入格式

The first line of the input gives the number of test cases, TT. TT test cases follows. The first line of each case has three integers NN, MM, and QQ, representing the number of balloons, the number of height levels, and the amount of energy available.

The second line has MM integers; the jjth value on this line (counting starting from 00) is the wind velocity at height jj.

Then, NN more lines follow. The iith of these lines consists of two integers, PiP_i and HiH_i, representing the position and height of the iith balloon.

输出格式

For each test case, output one line containing "Case #x: y", where xx is the test case number (starting from 1) and yy is the minimum number of time units needed to collect all of the balloons, returns IMPOSSIBLE if it's impossible to collect all the balloons using the energy given.

2
2 4 1
2 1 -2 -1
3 3
-2 1
1 3 1
1 -1 -2
-2 2
Case #1: 2
Case #2: IMPOSSIBLE

提示

Here is an example:

:::align{center} :::

In the sample case, there are 22 balloons in the sky, and you have 11 energy point to use. The best solution is to immediately spend 11 energy point to move the balloon at position 33, height 33 down to height 22. Once you've done that, it will take 22 time units for both balloons to reach the tower.

Limits

Small dataset (Test Set 1 - Visible)

1T1001 \le T \le 100.

1N101 \le N \le 10.

1M101 \le M \le 10.

10Vj10-10 \le V_j \le 10.

1Q101 \le Q \le 10.

0Hi<M0 \le H_i < M.

10Pi10-10 \le P_i \le 10.

Large dataset (Test Set 2 - Hidden)

1T251 \le T \le 25.

1N1001 \le N \le 100.

1M10001 \le M \le 1000.

100Vj100-100 \le V_j \le 100.

1Q100001 \le Q \le 10000.

0Hi<M0 \le H_i < M.

10000Pi10000-10000 \le P_i \le 10000.