P1583 magic photos and p1583 magic photos
Description
A total of n (n ≤ 20000) People (with 1 -- n number) Ask Jia for a photo, and Jia can only give the photo to k of them. Jia assigned an initial weight W [I] To everyone based on their relationship. Then sort the initial weights from large to small, and each person has a serial number D [I] (the value is also 1 -- n ). According to the serial number, the modulo value of 10 is divided into 10 categories. That is to say, the value of the class serial number C [I] for each person is (D [I]-1) mod 10 + 1. Obviously, the class serial number is 1-10. The person in class I will receive an additional weight of E [I. What you need to do is to find the k people with the maximum weight after adding the additional weight, and output their numbers. In sorting, if the two persons have the same W [I], the smaller number takes precedence.
Input/Output Format
Input Format:
The first line is the two integers separated by spaces, n and k.
The second row provides 10 positive integers from E [1] to E [10].
The third row provides n positive integers. The number of I represents the weight of the person numbered with I W [I].
Output Format:
Only one row of k integers separated by spaces are output, indicating the number of the final W [I] from high to low.
Input and Output sample
Input example #1:
10 101 2 3 4 5 6 7 8 9 102 4 6 8 10 12 14 16 18 20
Output sample #1:
10 9 8 7 6 5 4 3 2 1
1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <cmath> 5 # include <algorithm> 6 using namespace std; 7 int E [11]; 8 struct node 9 {10 int cs; // initial 11 int xh; // serial number 12 int bh; // number 13 int lbxh; // category No. 14} a [500001]; 15 int comp (const node & a, const node & B) 16 {17 if (. cs! = B. cs) 18 return. cs> B. cs; 19 else20 return. bh <B. bh; 21} 22 int main () 23 {24 int n, k; 25 scanf ("% d", & n, & k ); 26 for (int I = 1; I <= 10; I ++) 27 scanf ("% d", & E [I]); 28 for (int I = 1; I <= n; I ++) 29 scanf ("% d", & a [I]. cs), a [I]. bh = I; 30 sort (a + 1, a + n + 1, comp); 31 32 for (int I = 1; I <= n; I ++) 33 a [I]. xh = I; 34 35 for (int I = 1; I <= n; I ++) 36 a [I]. cs + = E [(a [I]. xh-1) % 10 + 1]; 37 38 sort (a + 1, a + n + 1, comp); 39 for (int I = 1; I <= k; I ++) 40 printf ("% d", a [I]. bh); 41 return 0; 42}