cswork / OA打开练习工作台

SalesforceOA #35

Plan Cuts

估计中等可在线判题

考点(AI 标注)贪心调度双指针滑窗

A rod already has the lengths of all its final segments marked in order. The machine can only cut an existing rod of length at least minLength, and each cut splits it into two rods at one mark that has not been cut yet. Determine whether there is an order that completes the cuts at all marks.

输入格式

The input gives n, the n segment lengths, and minLength. The original has no numeric bounds, and the extra ranges in the catalog have no basis in the original text; this site adds 2≤n≤200000, each segment 1..10^9, 1≤minLength≤10^18. n≥2 guarantees that there really is a last cut.

输出格式

Output Possible if it can be done, otherwise Impossible.

样例 1

输入:

4
3 5 4 3
9

输出:

Possible

样例 2

输入:

3
4 2 3
7

输出:

Impossible

样例 3

输入:

3
4 3 2
7

输出:

Possible

样例说明

The outputs of the three public examples are, in order: Possible; Impossible; Possible. They have been checked by independent enumeration or direct simulation.