http://acm.hdu.edu.cn/showproblem.php?pid=1031

题意 :n个人,每个人对m件衣服打分,每个人对第 i 件衣服的打分要加起来,选取和前 k 高的输出他们的编号 i ,然后这k个的序号要倒序输出

思路 :快排一下就行了。这道题坑了我好几遍TLE,原因是我交的语言是G++而不是C++。。。。。。

#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std ;
struct node
{
double sati ;
int order ;
} a[] ;
bool cmp(const node &x,const node &y)
{
return x.sati == y.sati ? (x.order < y.order) : (y.sati < x.sati );
}
bool cmp1(const node &x,const node &y)
{
return x.order > y.order ;
}
int main()
{
int n,m,k ;
double b ;
while(scanf("%d %d %d",&n,&m,&k)!=EOF)
{
for(int i = ; i < m ; i++)
a[i].sati = ;
for(int i = ; i < n ; i++)
{
for(int j = ; j < m ; j++)
{
cin>>b ;
a[j].sati += b ;
a[j].order = j+ ;
}
}
sort(a,a+m,cmp) ;
sort(a,a+k,cmp1) ;
for(int i = ; i < k- ; i++ )
cout<<a[i].order<<" " ;
cout<<a[k-].order<<endl ;
}
return ;
}

HDU 1031 Design T-Shirt的更多相关文章

  1. 杭电 HDU 1031 Design T-Shirt

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

  2. 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 ...

  3. HDU 1031(服装打分 **)

    题意是有 n 个人要对 m 件服装打分,按总分从高到低排序,再将总分排在前 k 名的服装按编号的从高到低输出,结构体排序. 代码如下: #include <bits/stdc++.h> u ...

  4. HDU 1007Quoit Design(最近点问题)

    最近点问题:二维平面中有n(n很大)个点,求出距离最近的两个点 思路:因为n的值很大,所以暴力和dp都行不通了吧!分治法就挺好的. 将区间一半一半的分开,直到分成只有一个点或两个点的时候! 对于只有两 ...

  5. 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 ...

  6. 【HDOJ】1031 Design T-Shirt

    qsort直接排序. #include <stdio.h> #include <string.h> #include <stdlib.h> #define MAXN ...

  7. 最近点对问题 HDU Quoit Design 1007 分治法

    #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #i ...

  8. 8-7-Exercise

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

  9. 【English】七、常见动词

    一.动词: touch.hear.say.listen touch [tʌtʃ] 触摸 I touch the cat. They touch the elephant. hear  [hɪr] 听到 ...

随机推荐

  1. 【leetcode】12. Integer to Roman

    题目描述: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range fr ...

  2. CAD输出的局部平面坐标数据配准转换到WGS84坐标系

             局部平面坐标                                             平移纠正到常用平面坐标系下的坐标            转换后的地理坐标 采用两 ...

  3. 考虑virtual函数以外的其它选择

    详情见<Effective C++>item35 1.使用non-virtual interface(NVI)手法,这是Template Method设计模式的一种特殊形式. 它以publ ...

  4. SQLite学习心得

    SQLite是一款很有名气的小型开源跨平台数据库,作为目前最流行的开源嵌入式关系型数据库,在系统结构设计中正在扮演着越来越重要的角色. 本文主要沿着 http://www.cppblog.com/we ...

  5. linux之Gcc使用

    本篇文章摘自 http://blog.csdn.net/ljzcom/article/details/7213101 对于Gcc自带的很多命令行,只有具体编程里面用到了或者看到别人真真用到的,用的目的 ...

  6. .NET Web后台动态加载Css、JS 文件,换肤方案

    后台动态加载文件代码: //假设css文件:TestCss.css #region 动态加载css文件 public void AddCss() { HtmlGenericControl _CssFi ...

  7. c#winform,制作可编辑html编辑器

    大神勿喷,新手记笔记 材料 网上下载kindeditor,动手在写个htmldome,图中的e.html.然后全部扔到了bin/debug下面,(x86是要扔到bin/x86/debug) 中间bod ...

  8. JS禁用和启用鼠标滚轮滚动事件

    // left: 37, up: 38, right: 39, down: 40, // spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: ...

  9. 搭建pptpd实现vpn

    PPTP(Point to Point Tuneling Protocol,点对点隧道协议)是一种主要用于VPN的数据链路层网络协议. 环境:debian 7.0 在linux下安装pptpd服务实现 ...

  10. win7 vs2008 激活

    参考:http://www.cnblogs.com/wgx0428/archive/2012/08/07/2627380.html win7需要管理员方式运行软件,才能看到输入框 软件:http:// ...