题意是有 n 个人要对 m 件服装打分,按总分从高到低排序,再将总分排在前 k 名的服装按编号的从高到低输出,结构体排序。

代码如下:

 #include <bits/stdc++.h>
using namespace std;
struct shirt
{
int num;
double price;
}t[];
bool cmp1(shirt a,shirt b)
{
return a.price>b.price;
}
bool cmp2(shirt a,shirt b)
{
return a.num>b.num;
}
int main()
{
int n,m,k;
double tmp;
while(~scanf("%d%d%d",&n,&m,&k))
{
for(int i = ; i < m; ++i)
{
t[i].price = ;
t[i].num = i+;
}
for(int i = ; i < n; ++i)
for(int j = ; j < m; ++j)
{
scanf("%lf",&tmp);
t[j].price += tmp;
}
sort(t,t+m,cmp1);
sort(t,t+k,cmp2);
for(int i = ; i < k-; ++i)
printf("%d ",t[i].num);
printf("%d\n",t[k-].num);
}
return ;
}

HDU 1031(服装打分 **)的更多相关文章

  1. HDU 1031 Design T-Shirt

    http://acm.hdu.edu.cn/showproblem.php?pid=1031 题意 :n个人,每个人对m件衣服打分,每个人对第 i 件衣服的打分要加起来,选取和前 k 高的输出他们的编 ...

  2. hdu 1031 (partial sort problem, nth_element, stable_partition, lambda expression) 分类: hdoj 2015-06-15 17:47 26人阅读 评论(0) 收藏

    partial sort. first use std::nth_element to find pivot, then use std::stable_partition with the pivo ...

  3. 杭电 HDU 1031 Design T-Shirt

    Design T-Shirt Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T ...

  4. HDU 1031.Design T-Shirt【结构体二次排序】【8月21】

    Design T-Shirt Problem Description Soon after he decided to design a T-shirt for our Algorithm Board ...

  5. 8-7-Exercise

    链接:第二次小练 这次是我们这组出的题目~我出了一道......B-Prison rearrangement,感觉有点复杂~不过其实题目想通了还是很简单的...... @荆红浅醉出的是A.C.D,@从 ...

  6. 【动态规划】HDU 1081 & XMU 1031 To the Max

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1081 http://acm.xmu.edu.cn/JudgeOnline/problem.php?i ...

  7. hdu 2014 青年歌手大奖赛_评委会打分

    题意: 输入N个数,去掉最大和最小的数,求剩余的数的平均数. 解法: 找到分别最大和最小的数,然后从总和中减去他们,再求平均数(不要排序): 1: #include<stdlib.h> 2 ...

  8. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  9. hdu 2426 Interesting Housing Problem 最大权匹配KM算法

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2426 For any school, it is hard to find a feasible ac ...

随机推荐

  1. 【XSY2691】中关村 卢卡斯定理 数位DP

    题目描述 在一个\(k\)维空间中,每个整点被黑白染色.对于一个坐标为\((x_1,x_2,\ldots,x_k)\)的点,他的颜色我们通过如下方式计算: 如果存在一维坐标是\(0\),则颜色是黑色. ...

  2. 【hdu 5628】Clarke and math (Dirichlet卷积)

    hdu 5628 Clarke and math 题意 Given f(i),1≤i≤n, calculate \(\displaystyle g(i) = \sum_{i_1 \mid i} \su ...

  3. [luogu3391][bzoj3223]文艺平衡树【splay】

    题目描述 您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:翻转一个区间,例如原有序序列是5 4 3 2 1,翻转区间是[2,4]的话,结果是5 2 3 4 1 分析 ...

  4. Nmap扫描常用参数

    TCP: nmap -sC -sS -sV -p 1-65535 -A -v -v -oX filename.xml -Pn ip 类似: nmap -sS -A -sV -vv -sC -PN -p ...

  5. luogu3242 接水果 (整体二分+树状数组)

    考虑整体二分,问题就变成了每个(水果)路径有多少个满足条件(权值)的(盘子)子路径 考虑一个盘子(a,b)表示两端点(不妨设dfn[a]<dfn[b]),那么他能接到的水果(u,v)一定满足(不 ...

  6. __init__和__new__的异同

    实例化类的流程: 1.p = Person(name, age)2.首先执行使用name和age参数来执行Person类的__new__方法,这个__new__方法会 返回Person类的一个实例(p ...

  7. centos7/rhel7安装较高版本ruby2.2/2.3/2.4+

    环境需求: 在Centos7.3中,通过yum安装ruby的版本是2.0.0,但是如果有些应用需要高版本的ruby环境,比如2.2,2.3,2.4...那就有点麻烦了,譬如:我准备使用redis官方给 ...

  8. sublime安装说明

    安装Install package https://www.cnblogs.com/lixuwu/p/5693624.html 常用配置 Perference → Settings – User,用下 ...

  9. page-break-after:always不能正常工作

    https://stackoverflow.com/questions/9595412/ie7-ie8-page-break-afteralways-not-working 最近在打印网页的时候发现 ...

  10. 把本人基于Dubbo的毕业设计分享粗来~

    这个毕业设计不是太让我满意,可能时间关系吧,但是现在工作了我也懒得没时间去完善了[目前也就有一个功能没完成,就是给产品经理送绿帽子的模块] 项目地址:GitHub 技术栈:Spring+SpringM ...