HDU ACM 1031 Design T-Shirt 水题

分析:给你n个人M件衣服, 选出前K件衣服评价最大值,注意要输出的是编号,编号从大到小。两次排序即可。

#include<iostream>
#include<algorithm>
using namespace std;

struct node
{
	double m;
	int id;
};

bool cmp(const node& a,const node& b)
{
	if(a.m!=b.m)
		return a.m>b.m;
	else
		return a.id<b.id;
}

bool cmp2(const node& a,const node& b)  //按照编号排序
{
	return a.id>b.id;
}

int main()
{
	int n,m,k;
	double t;
	int i;
	node s[10000];

	while(cin>>n>>m>>k)
	{
		for(i=0;i<m;i++)
			s[i].m=0;
		while(n--)
			for(i=0;i<m;i++)
			{
				cin>>t;
				s[i].m+=t;
				s[i].id=i;
			}
		sort(s,s+m,cmp);
		sort(s,s+k,cmp2);
		for(i=0;i<k;i++)
		{
			cout<<s[i].id+1;
			if(i<k-1)
				cout<<' ';
		}
		cout<<endl;
	}
    return 0;
}
时间: 2024-08-03 16:42:24

HDU ACM 1031 Design T-Shirt 水题的相关文章

HDU ACM 1017 A Mathematical Curiosity 水题

分析:水题,但要注意格式. #include<iostream> using namespace std; int core(int n,int m) { int i,j,ans=0; for(i=1;i<n;i++) for(j=i+1;j<n;j++) if((i*i+j*j+m)%(i*j)==0) ans++; return ans; } int main() { int T,t,n,m; bool fg=false; scanf("%d",&T

HDU ACM 1073 Online Judge -&gt;字符串水题

分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read(char p[]) { getchar(); gets(tmp); while(gets(tmp)) { if(strcmp(tmp,"END")==0) break; if(strlen(tmp)!=0) strcat(p,tmp); strcat(p,"\n");

HDU ACM 5224 Tom and paper 水题+暴力枚举

分析:因为长和宽都是整数,所以枚举判断是不是整数,再取最小的即可. #include<iostream> #include<cmath> using namespace std; int main() { int min; int a,i,T; ios::sync_with_stdio(false); cin>>T; while(T--) { cin>>a; min=1000000000; for(i=1;i<=sqrt(a);i++) if(a%i=

HDU 4007 Dave (基本算法-水题)

Dave Problem Description Recently, Dave is boring, so he often walks around. He finds that some places are too crowded, for example, the ground. He couldn't help to think of the disasters happening recently. Crowded place is not safe. He knows there

HDU 4022 Bombing(基本算法-水题)

Bombing Problem Description It's a cruel war which killed millions of people and ruined series of cities. In order to stop it, let's bomb the opponent's base. It seems not to be a hard work in circumstances of street battles, however, you'll be encou

hdu 4274 Spy&#39;s Work(水题)

Spy's Work Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1266    Accepted Submission(s): 388 Problem Description I'm a manager of a large trading company, called ACM, and responsible for the

HDU 1862 EXCEL排序 (排序水题)

Problem Description Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. Input 测试输入包含若干测试用例.每个测试用例的第1行包含两个整数 N (<=100000) 和 C,其中 N 是纪录的条数,C 是指定排序的列号.以下有 N 行,每行包含一条学生纪录.每条学生纪录由学号(6位数字,同组测试中没有重复的学号).姓名(不超过8位且不包含空格的字符串).成绩(闭区间[0, 100]内的整数)组成,每个项目间用1个空格隔开.当读到 N=0 时,全部输入结

HDU 1800 Flying to the Mars (水题)

Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11099    Accepted Submission(s): 3572 Problem Description In the year 8888, the Earth is ruled by the PPF Empire . As the popul

HDU 1520 Anniversary party 树DP水题

非常水的树DP,状态为当前为i,上级来没来 然后跑一遍记忆化搜索即可 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <climits> #include <string> #include <iostream> #include <map> #include <cstdlib>