#P1583. Photo Selection Problem

    ID: 14869 Type: Default 1000ms 256MiB

Photo Selection Problem

Photo Selection Problem

Jiajia has n people (numbered from 1 to n) asking for her photo, but she can only give the photo to k people. Each person has an initial weight \(W_i\) (indicating how close they are to Jiajia). Jiajia first sorts the n people by \(W_i\) in non‐increasing order. After sorting, the person in the i-th position is assigned a rank \(D_i (1 \le D_i \le n)\).

Then, each person is assigned to one of 10 categories based on the value of \((D_i-1) \bmod 10 + 1\). In other words, the category number for person \(i\) is \[ C_i = ((D_i-1) \bmod 10) + 1, \] and \(C_i \in \{1,2,\dots,10\}\). Each person in category \(i\) will receive an extra weight of \(E_i\). Thus, the final weight of person \(i\) is: \[ FinalWeight_i = W_i + E_{C_i}. \]

Your task is to choose the k persons with the highest final weights. In the sorting for selecting these persons, if two people obtain the same extra weight \(E\) (i.e. if \(E_{C}\) are equal), the one with the smaller original index is considered first. Finally, output the original indices of the chosen persons in increasing order (sorted by their number).

inputFormat

The input consists of three lines:

  1. The first line contains two integers \(n\) and \(k\) (\(1 \le k \le n\)).
  2. The second line contains \(n\) space-separated integers \(W_1, W_2, \dots, W_n\), representing the initial weights.
  3. The third line contains 10 space-separated integers \(E_1, E_2, \dots, E_{10}\), representing the extra weights for categories 1 through 10.

outputFormat

Output the original indices of the selected k persons in a single line, sorted in increasing order and separated by spaces.

sample

5 2
10 20 30 40 50
1 2 3 4 5 6 7 8 9 10
4 5