#P1977. 出租车拼车
出租车拼车
Description
Suppose OIers plan to carpool. Time is the current moment. The fare from the school gate to the destination is yuan, charged per taxi ride regardless of how many OIers are inside. Assume the contest starts exactly at minutes, so any taxi that passes the gate after minutes can be ignored. You are given the arrival times and remaining seats of all taxis that pass the gate within these minutes. For each taxi, the OIers may choose to let up to people board (possibly ), or skip this taxi entirely.
Time is money: each OIer’s waiting time in minutes at the gate is counted as spending the same amount of money. For example, if little x waits minutes, that means he spends an extra yuan.
Under the requirement that all OIers can reach the venue before the contest starts, compute the minimum total amount of money they need to spend.
Input Format
Each test case starts with four integers , , , , as described above.
Then follow lines. The -th line gives that the -th taxi arrives at minute , and its number of remaining seats is .
Times are given in chronological order.
Output Format
For each test case, output one line. If all of them can reach the venue before the contest starts, output a single integer representing the minimum amount of money (in yuan). Otherwise, output impossible.
2 2 10 5
1 1
2 2
14
Hint
Constraints: For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号