#C11211. Application Executor

    ID: 40503 Type: Default 1000ms 256MiB

Application Executor

Application Executor

You are given a set of applications where each application consumes a certain amount of CPU and is assigned a priority level. The goal is to determine whether it is possible to execute all applications sequentially without exceeding the given CPU resource limit. The applications must be executed in order of increasing priority and, if priorities are equal, in the order of their indices (1-indexed). If executing an application would cause the total CPU consumption to exceed the available resource, then the execution is deemed impossible.

The formal requirement is to sort the applications by their priority and then by their index. Then, accumulate the CPU consumption and check at every step:

( \text{if } \sum_{i=1}^{j} cpu[i] > t \text{ for any } j, \text{ output } \texttt{IMPOSSIBLE} ). If all applications can be executed, output ( \texttt{POSSIBLE} ) and the order of execution.

inputFormat

The input is given via standard input (stdin) and consists of three lines:

  1. The first line contains three integers separated by spaces: ( n ) (the number of applications), ( k ) (the number of distinct priority levels), and ( t ) (the maximum available CPU resource).

  2. The second line contains ( n ) space-separated integers representing the CPU consumption of each application.

  3. The third line contains ( n ) space-separated integers representing the priority level for each application.

outputFormat

The output should be printed to standard output (stdout).

If it is possible to execute all applications under the given CPU constraint, print "POSSIBLE" on the first line, followed by the execution order (a sequence of indices separated by spaces) on the second line. Otherwise, print "IMPOSSIBLE" on a single line.## sample

4 3 100
10 20 30 25
3 1 2 1
POSSIBLE

2 4 3 1

</p>