HDU 1031 Design T-shirt

Source: Internet
Author: User

Design T-shirt

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 7637 Accepted Submission (s): 3616


Problem Descriptionsoon after he decided to design a T-shirt for we algorithm Board on free-city BBS, Xka found that he w As trapped by all kinds of suggestions from everyone on the board. It is indeed a mission-impossible to the everybody perfectly satisfied. So he took a poll to collect people ' s opinions. Here is 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 to his design. He needs the pick for him, the K elements such, the total number of satisfaction are maximized.

Inputthe input consists of multiple test cases. For each case, the first line contains three positive integers n, m and K where N was the number of people, M is the number of design elements, and K is the number of elements Xka would 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 on one line the indices of the K elements you would suggest xka to take into consideration So, the total number of satisfaction is maximized. If there is more than one solutions, you must the output of the one with minimal indices. The indices start from 1 and must is printed in non-increasing order. There must be exactly one space between a adjacent indices, and no extra space at the end of the line.

Sample INPUT3 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 OUTPUT6 5 3 12 1

Authorchen, Yue

Sourcecyjj ' s Funny Contest #1, killing in Seconds

RECOMMENDIGNATIUS.L | We have carefully selected several similar problems for you:1036 1032 1039 1038 1062 Simple Sort, note test instructions, and input test data have decimal points, so is double type 。 Test instructions: Give n personal satisfaction with M-piece t-shirts, output this m-piece t-shirt in descending order of the total satisfaction degree before the K-large. Multiple sets of inputs, each set of use cases the first behavior of three integers n,m,k, followed by a n*m matrix representing n personal satisfaction with M-piece T-shirts, with end-of-file input. For each set of use cases, the output comprehensive satisfaction is before the K-Large (output by number descending). Attached code:
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <algorithm>5 using namespacestd;6 structnode7 {8     intT;9     DoubleW;Ten} ss[10005]; One BOOLCMP1 (node A,node b) A { -     returnA.w>B.W; - } the BOOLCMP2 (node A,node b) - { -     returnA.t>b.t; - } + intMain () - { +     intn,m,i,j,k; A     Doubles; at      while(~SCANF ("%d%d%d",&n,&m,&k)) -     { -memset (SS,0,sizeof(ss)); -          for(j=1; j<=n; J + +) -         { -              for(i=1; i<=m; i++) in             { -ss[i].t=i; toscanf"%LF",&s); +Ss[i].w+=s;//the satisfaction of everyone in each piece of clothing accumulates -             } the         } *  $Sort (ss+1, ss+m+1, CMP1);//order of satisfaction from big to smallPanax NotoginsengSort (ss+1, ss+k+1, CMP2);//output sequence number from large to small sort -          for(i=1; i<=k; i++) the         { +             if(i!=1) printf (" "); Aprintf"%d", ss[i].t); the         } +printf"\ n"); -     } $     return 0; $}

HDU 1031 Design T-shirt

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.