#P1583. 魔法照片

魔法照片

Description

There are nn people (numbered 1n1 \sim n) asking Jiajia for photos, but Jiajia can only give photos to kk of them. Jiajia assigns each person an initial weight WiW_i based on how close they are. Then she sorts the initial weights in descending order, and each person gets a rank DiD_i (also taking values 1n1 \sim n). When determining DiD_i, if two people have the same WiW_i, the one with the smaller index comes first.

According to the rank modulo 1010, these people are divided into 1010 categories. Specifically, define each person’s category index CiC_i as (Di1)mod10+1(D_i-1)\bmod 10 + 1, so CiC_i takes values 1101 \sim 10. People in category ii receive an extra weight EiE_i.

Let the final weight be Fi=Wi+ECiF_i = W_i + E_{C_i}. Your task is to find the kk people with the largest final weights and output their indices. In the final sorting, if two people have the same FiF_i, the one with the smaller index comes first.

Input Format

  • The first line contains two integers separated by a space: nn and kk.
  • The second line contains 1010 positive integers: E1E10E_1 \sim E_{10}.
  • The third line contains nn positive integers, where the ii-th number is the weight WiW_i of the person with index ii.

Output Format

Output one line with kk integers separated by spaces: the indices of the people with the highest to lowest final weights FiF_i.

10 10
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20

10 9 8 7 6 5 4 3 2 1

Hint

Constraints: For 100%100\% of the testdata, 1n200001 \leq n \leq 20000, 1kn1 \leq k \leq n. All values are guaranteed to fit in the range of int.

Translated by ChatGPT 5