HDU 1031 design T-shirt

Source: Internet
Author: User

Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1031

Description: first sort by satisfaction, select the first K, and then sort by sequence number.

Problem descriptionsoon after he decided to design a T-shirt for our algorithm board on free-city BBS, xka found that he was trapped by all kinds of suggestions from everyone on the board. it is indeed a mission-impossible to have everybody perfectly satisfied. so he took a poll to collect people's opinions. here are what he obtained: N people voted for M design elements (such as the ACM-ICPC logo, big names in computer science, well-known graphs, etc .). everyone assigned each element a number of satisfaction. however, xka can only put K (<= m) elements into his design. he needs you to pick for him the k elements such that the total number of satisfaction is maximized.

 

Inputthe input consists of multiple test cases. for each case, the first line contains three positive integers n, m and K where N is the number of people, M is the number of design elements, and k is the number of elements xka will put into his design. then n lines follow, each contains M numbers. the J-th number in the I-th line represents the I-th person's satisfaction on the J-th element.

 

Outputfor each test case, print in one line the indices of the k elements you wowould suggest xka to take into consideration so that the total number of satisfaction is maximized. if there are more than one solutions, you must output the one with minimal indices. the indices start from 1 and must be printed in non-increasing order. there must be exactly one space between two adjacent indices, and no extra space at the end of the line.

 

Sample Input
3 6 42 2.5 5 1 3 45 1 3.5 2 2 21 1 1 1 1 103 3 21 2 32 3 13 1 2
 

 

Sample output
6 5 3 12 1
 

# Include <stdio. h>
Struct s
{
Int X;
Double Y;
} A [300], B;
Int main ()
{
Int n, m, K;
While (scanf ("% d", & N, & M, & K )! = EOF)
{

Double T;
Int I, j, Z;
For (I = 0; I <m; I ++)
A [I]. Y = 0;
For (I = 0; I <n; I ++)
{
For (j = 0; j <m; j ++)
{
Scanf ("% lf", & T );
A [J]. x = J + 1;
A [J]. Y = A [J]. Y + T;
}
}
For (I = 0; I <m-1; I ++) // sort the recognition degree.
For (j = 0; j <m-i-1; j ++)
If (A [J]. Y <A [J + 1]. Y)
{
B = A [J];
A [J] = A [J + 1];
A [J + 1] = B;
}
For (I = 0; I <K-1; I ++) // sort the numbers
For (j = 0; j <k-i-1; j ++)
If (A [J]. x <A [J + 1]. X)
{
B = A [J];
A [J] = A [J + 1];
A [J + 1] = B;
}

For (I = 0; I <K-1; I ++)
Printf ("% d", a [I]. X );
Printf ("% d \ n", a [I]. X );
}
}

 

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.