Rokua p1583--Magic photo (struct sort)

Source: Internet
Author: User

Https://www.luogu.org/problem/show?pid=1583#sub

Title Description

A total of n (n≤20000) individuals (with the 1--n number) to Allison to photos, and Allison can only send photos to the K-person. Allison assigns an initial weight to each person according to the degree of their relationship w[i]. The initial weights are then sorted from large to small, each with an ordinal d[i] (the value is also 1--n). These people are divided into 10 categories according to the value of this sequence number to 10 modulo. That is, the value of defining each person's category ordinal c[i] is (d[i]-1) mod 10 +1, obviously the value of the class ordinal is 1--10. The person in Class I will be given an additional e[i] weight. All you need to do is to get the extra weights after the ultimate weight of the k individuals, and output their numbers. In the sort, if two people's w[i] is the same, the number is small priority.

Input/output formatInput Format:

The first line enters two integers separated by spaces, N and K, respectively.

The second line gives 10 positive integers, respectively e[1] to e[10].

The third line gives the n positive integers, and the number of I represents the weight of the person numbered I w[i].

output Format:

Simply output a line of k integers separated by spaces, representing the final w[i] number of people from the highest to the lowest.

Input/Output sampleInput Sample # #:
10 101 2 3 4 5 6 7 8 9 102 4 6 8 10 12 14 16 18 20
Sample # # of output:
10 9 8 7 6 5 4 3 2 1

1#include <bits/stdc++.h>2 using namespacestd;3 structnode4 {5     intW;6     intID;7}num[20050];8 intCMP (node A,node b)9 {Ten     if(A.W==B.W)returna.id<b.id; One     Else  A     returnA.w>B.W; - } - intMain () the { -     intn,k; -     inte[ -]; -Cin>>n>>K; +      for(intI=1; i<=Ten; i++) -Cin>>E[i]; +      for(intI=1; i<=n;i++) A     { atCin>>NUM[I].W; -Num[i].id=i; -     } -Sort (num+1, num+n+1, CMP); -      for(intI=1; i<=n;i++) -num[i].w+=e[(I-1)%Ten+1]; inSort (num+1, num+n+1, CMP); -      for(intI=1; i<=k;i++) tocout<<num[i].id<<" "; +     return 0; -}

Rokua p1583--Magic photo (struct sort)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.