Popular driving range - Sort Ex-P1583 magic photo

P1583 magic photo
title describes
a total of n (n≤20000) Personal (number to 1-n) to Allison for a photo, while Allison can only individual photos to k them. Allison according to the degree and quality of their relationship to each person assigned an initial weight W [i]. Then the initial weights decreasing order, each have a number D [i] (the same value is 1-n). No. 10 according to this value modulo these people divided into 10 categories. That is the definition of each category number C [i] value (D [i] -1) mod 10 +1, the apparent value of the category number 1-10. I-class people will get extra weight E [i] of. You need to do is obtained after adding extra weight, the maximum weight of the final k individuals, and output their numbers. In sort, if two of W [i] the same, a small number of priority.

Input and output format
input format:

The first line input two integers separated by a space, respectively, n and k.

The second line 10 is given positive integers, respectively, E [1] to E [10].

The third line is given a positive integer n, denotes the i-th number of people i weights W [i].

Output formats:

Only one line of output of space-separated integers k, respectively, the final W [i] descending number of people.

Input Output Sample
Input Sample # 1:

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

Output Sample # 1:

10987654321
----------------
ideas: Arranging "Sort" weights "Sort

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 20000+10;
struct node{
	int id;
	int  w;
}p[maxn];
int n, k,D[11];
bool cmp(node a,node b){
	if(a.w == b.w) return a.id < b.id;
	return a.w > b.w;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i =1;i <= 10;i++)
	scanf("%d",&D[i]);
	for(int i = 0;i < n;i++)
	{
		scanf("%d",&p[i].w);
		p[i].id = i+1;
	}
  sort(p,p+n,cmp);
  for(int i = 0;i < n;i++)
  p[i].w += D[i % 10 + 1];
   //p[i].w += (D[i]-1) % 10 + 1;
  sort(p,p+n,cmp);
  for(int i = 0;i < k;i++)
  printf("%d ",p[i].id);
	return 0;
}
Published 80 original articles · won praise 1 · views 1485

Guess you like

Origin blog.csdn.net/zqhf123/article/details/104354671