"Sort" The art photos of Qi Qi

Source: Internet
Author: User

Title Description

Qi Qi is a beautiful little girl,. Many people say she is like a doll. One day, she also took her art photos back to the kindergarten to show off, perhaps because of Qi Qi's art photo is too beautiful, many children are looking for her to art photos, those photos are very precious, she should give the photos to whom?
A total of n individuals (with 1~n number) Shang to photos. And Qi Qi can only give photos to the K-man. In terms of how good and bad the relationship is with them, Qi Qi gives each person an initial weight of 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 category ordinal is l~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. Weighted values are positive integers. In the sort, if two people's w[i] is the same, the number is small priority.

Enter a total of 3 lines:
The 1th line outputs two integers separated by spaces, N (o<n≤50000) and K (0≤k≤n) respectively;
The 2nd line gives 10 positive integers, respectively e[1] to e[10] (0<e[i]≤50000);
The 3rd line gives the n positive integers, and the number of I represents the weight of the person numbered I w[i] (o<w[i]≤50000).

The output simply outputs 1 lines of k integers separated by spaces, representing the final w[i] number of people from the highest to the lowest.

Sample input
10 101 2 3 4 5 6 7 8 9 102 4 6 8 10 12 14 16 18 20

Sample output
10 9 8 7 6 5 4 3 2 1

The title means let you take w[i] according to the order from small to large, get each person's serial number, and then go to the serial number to get the category sequence number, plus the corresponding E value, the number is the first to give you the sequence.
1#include <bits/stdc++.h>2 using namespacestd;3typedefLong Longll;4 structnode5 {6     intId,wi;7}mp[50005];8 BOOLCMP (node A,node b)9 {Ten     if(A.WI==B.WI)returna.id<b.id; One     returnA.wi>B.wi; A } - intn,k,e[ -],w[50005]; - intMain () the { -scanf"%d%d",&n,&k); -      for(intI=1; i<=Ten; i++) -scanf"%d",&e[i]); +      for(intI=1; i<=n;i++) -     { +scanf"%d",&w[i]); AMp[i].wi=W[i]; atMp[i].id=i; -     } -Sort (mp+1, mp+1+n,cmp); -      for(intI=1; i<=n;i++) -mp[i].wi+=e[(I-1)%Ten+1]; -Sort (mp+1, mp+1+n,cmp); in      for(intI=1; i<=k;i++) -     { to         if(i!=1) printf (" "); +printf"%d", mp[i].id); -     } theprintf"\ n"); *     return 0; $}
View Code

"Sort" The art photos of Qi Qi

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.