#P1583. 魔法照片
魔法照片
Description
There are people (numbered ) asking Jiajia for photos, but Jiajia can only give photos to of them. Jiajia assigns each person an initial weight based on how close they are. Then she sorts the initial weights in descending order, and each person gets a rank (also taking values ). When determining , if two people have the same , the one with the smaller index comes first.
According to the rank modulo , these people are divided into categories. Specifically, define each person’s category index as , so takes values . People in category receive an extra weight .
Let the final weight be . Your task is to find the people with the largest final weights and output their indices. In the final sorting, if two people have the same , the one with the smaller index comes first.
Input Format
- The first line contains two integers separated by a space: and .
- The second line contains positive integers: .
- The third line contains positive integers, where the -th number is the weight of the person with index .
Output Format
Output one line with integers separated by spaces: the indices of the people with the highest to lowest final weights .
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 of the testdata, , . All values are guaranteed to fit in the range of int.
Translated by ChatGPT 5
京公网安备 11011102002149号