#C9503. Card Pack Possibility Check

    ID: 53604 Type: Default 1000ms 256MiB

Card Pack Possibility Check

Card Pack Possibility Check

You are given N card packs, each containing a certain number of cards. There are M players. For each player, you are given a target number of cards (T) and the maximum number of packs (k) that they are allowed to open. Your task is to determine whether each player can achieve their target by selecting up to k packs such that the total number of cards is maximized.

The optimal strategy is to choose the packs with the highest number of cards. Mathematically, if a player is allowed to open k packs, let the k largest card values be \(p_1, p_2, \dots, p_k\). The player can achieve the target if and only if:

[ \sum_{i=1}^{k} p_i \geq T ]

Output "Possible" if the target can be achieved, otherwise output "Not Possible".

inputFormat

The input is read from standard input (stdin) in the following format:

  1. The first line contains an integer N, the number of card packs.
  2. The second line contains N space-separated integers representing the number of cards in each pack.
  3. The third line contains an integer M, the number of players.
  4. The fourth line contains M space-separated integers representing the target card count for each player.
  5. The fifth line contains M space-separated integers representing the maximum number of packs each player can open.

outputFormat

For each player (in the order of input), print a single line containing either "Possible" if the player can achieve the target using up to the allowed number of packs, or "Not Possible" if they cannot.

## sample
5
3 5 2 8 7
4
10 15 9 14
2 3 1 2
Possible

Possible Not Possible Possible

</p>