vjudge B - Design T-Shirt

思路:水题,模拟即可。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,k;
struct nond{
    double val;int id;
}pe[100001];
int cmp1(nond a,nond b){
    if(a.val==b.val)    return a.id<b.id;
    return a.val>b.val;
}
int cmp2(nond a,nond b){
    return a.id>b.id;
}
int main(){
    while(scanf("%d%d%d",&n,&m,&k)!=EOF){
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++){
                double x;scanf("%lf",&x);
                pe[j].val+=x;
            }
        for(int i=1;i<=m;i++)    pe[i].id=i;
        sort(pe+1,pe+1+m,cmp1);
        sort(pe+1,pe+1+k,cmp2);
        for(int i=1;i<k;i++)
            cout<<pe[i].id<<" ";
        cout<<pe[k].id<<endl;
        memset(pe,0,sizeof(pe));
    }
}

 

posted @ 2018-04-14 19:33  一蓑烟雨任生平  阅读(173)  评论(0编辑  收藏  举报