hdoj-1031-Design T-Shirt
/* 两次排序,搞定 */ #include <cstring> #include <iostream> #include <algorithm> using namespace std; struct node { int key; double sum; bool operator <(const node& para) const { if (sum > para.sum )return true; else if (sum == para.sum) { if (key > para.key) return true; else return false; }else return false; } }arr[50000]; bool cmp(node a, node b) { return a.key > b.key; } int main() { int n,m ,k; while (cin>>n>>m>>k) { memset(arr, 0, sizeof(arr)); for (int i=0; i<n; i++) { for (int j=0; j<m; j++) { double tmp; scanf("%lf", &tmp); arr[j].sum += tmp; arr[j].key = j; } } sort(arr, arr+m); sort(arr, arr+k, cmp); printf("%d", arr[0].key + 1); for (int i=1; i<k; i++) { printf(" %d",arr[i].key + 1); } printf("\n"); } return 0; }