#P6024. 机器人
机器人
Description
Now, Xiao W wants the robot to help him complete tasks.
Each task has two attributes: the money needed to complete it , and the success probability .
Xiao W needs to arrange the tasks in some order. Then, the robot will do the tasks in the following way:
- Start from the first task.
- After paying the cost to do task , if it succeeds, then continue to do task ; otherwise, restart from the first task.
- After successfully completing task , the process ends.
For example, when , one possible process is:
- Do task , fail.
- Do task , succeed.
- Do task , fail.
- Do task , succeed.
- Do task , succeed.
- Process ends, and the total cost is .
Now, Xiao W wants you, who are studying OI, to help him find an ordering that makes his expected cost as small as possible.
Input Format
The first line contains an integer , the number of tasks.
The next line contains integers , as described above.
The next line contains integers , where , and the meaning of is as described above.
Output Format
If it is impossible to complete the tasks no matter what, output one line with the string Impossible.
Otherwise, output one line with integers , which is a permutation of . This represents the task order: the -th arranged task is task in the input.
2
999 1
5000 10000
1 2
1
1
0
Impossible
Hint
Explanation for Sample 1: You can understand it intuitively. Since task is guaranteed to succeed, putting it last is definitely not worse.
Explanation for Sample 2: Obviously, this task can never be completed, because its success probability is .
Note: Whether the task succeeds or not, you always have to pay the cost to attempt it.
This problem uses . If your output is at least as good as the answer output (or both are Impossible), then you will get full score on this test point; otherwise, you will get score on this test point.
For some reason, this problem does not provide the to contestants.
Constraints:
For of the testdata, .
For another of the testdata, all are equal.
For another of the testdata, all are equal.
For all testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号