标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7637 Accepted Submission(s):
3616
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 using namespace std; 6 struct node 7 { 8 int t; 9 double w; 10 } ss[10005]; 11 bool cmp1(node a,node b) 12 { 13 return a.w>b.w; 14 } 15 bool cmp2(node a,node b) 16 { 17 return a.t>b.t; 18 } 19 int main() 20 { 21 int n,m,i,j,k; 22 double s; 23 while(~scanf("%d%d%d",&n,&m,&k)) 24 { 25 memset(ss,0,sizeof(ss)); 26 for(j=1; j<=n; j++) 27 { 28 for(i=1; i<=m; i++) 29 { 30 ss[i].t=i; 31 scanf("%lf",&s); 32 ss[i].w+=s; //每件衣服每个人的满意度累加 33 } 34 } 35 36 sort(ss+1,ss+m+1,cmp1); //满意度从大到小排序 37 sort(ss+1,ss+k+1,cmp2); //输出序号从大到小排序 38 for(i=1; i<=k; i++) 39 { 40 if(i!=1) printf(" "); 41 printf("%d",ss[i].t); 42 } 43 printf("\n"); 44 } 45 return 0; 46 }
标签:
原文地址:http://www.cnblogs.com/pshw/p/5358558.html