HDU 1031 Design T-shirt

Source: Internet
Author: User

Test instructions: Xka to design t-shirt, solicit the public satisfaction of each element. Enter 3 integers, respectively, to N, M, K, where n represents the number of participants in the score, M represents the total number of elements, and K represents the number of elements to be selected for Xka. Xka will select the highest score of the first k elements, if the same score, choose the index of small elements.
Idea: Record the total number of each m and index, with the structure of the storage, two times the sort is enough

Also note that the output format cannot have extra spaces.

1#include <iostream>2#include <algorithm>3#include <cmath>4 using namespacestd;5 Doublenum[1005][1005];6 structpoint{7     Doubletot;8     intindex;9}p[1005];Ten intx[1050]; One intCMP (point x,point y) A { -     returnX.tot>Y.tot; - } the intCop (point A,point b) - { -     returnA.index>B.index; - } + intMain () - { +     intn,m,k; A      while(SCANF (" %d%d%d", &n,&m,&k)! =EOF) { at          for(intJ,i=1; i<=n;++i) -              for(j=1; j<=m;++j) -scanf"%LF",&num[i][j]); -         intt=0; -          for(inti,j=1; j<=m;++j) { -             Doublesum=0; in              for(i=1; i<=n;++i) -sum+=Num[i][j]; top[t].tot=sum; +p[t].index=J; -++T; the         } *Sort (p,p+t,cmp); $Sort (p,p+K,cop);Panax Notoginsengprintf"%d", p[0].index); -          for(intI=1; i<k;++i) theprintf"%d", P[i].index); +printf"\ n"); A     } the}

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.