Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
1 #include <cstdio> 2 #include <cmath> 3 #include <cstring> 4 #include <ctime> 5 #include <iostream> 6 #include <algorithm> 7 #include <set> 8 #include <vector> 9 #include <sstream> 10 #include <queue> 11 #include <typeinfo> 12 #include <fstream> 13 #include <map> 14 #include <stack> 15 using namespace std; 16 #define INF 100000 17 typedef long long ll; 18 const int maxn=10010; 19 struct object{ 20 double v; 21 int id; 22 }a[maxn]; 23 bool cmp1(object a,object b){ 24 if(a.v!=b.v) return a.v>b.v; 25 else return a.id<b.id; 26 } 27 bool cmp2(object a,object b){ 28 return a.id>b.id; 29 } 30 int main() 31 { 32 int n,m,k; 33 while(scanf("%d%d%d",&n,&m,&k)==3){ 34 for(int i=0;i<m;i++) a[i].v=0; 35 while(n--){ 36 double tmp; 37 for(int i=0;i<m;i++){ 38 scanf("%lf",&tmp); 39 a[i].v+=tmp; 40 a[i].id=i+1; 41 } 42 } 43 sort(a,a+m,cmp1); 44 sort(a,a+k,cmp2); 45 for(int i=0;i<k-1;i++) 46 printf("%d ",a[i].id); 47 printf("%d\n",a[k-1].id); 48 } 49 return 0; 50 }
原文:http://www.cnblogs.com/RRirring/p/4729582.html