HDU 1031 Design T-Shirt
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的更多相关文章
- 杭电 HDU 1031 Design T-Shirt
Design T-Shirt Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- 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 ...
- HDU 1031(服装打分 **)
题意是有 n 个人要对 m 件服装打分,按总分从高到低排序,再将总分排在前 k 名的服装按编号的从高到低输出,结构体排序. 代码如下: #include <bits/stdc++.h> u ...
- HDU 1007Quoit Design(最近点问题)
最近点问题:二维平面中有n(n很大)个点,求出距离最近的两个点 思路:因为n的值很大,所以暴力和dp都行不通了吧!分治法就挺好的. 将区间一半一半的分开,直到分成只有一个点或两个点的时候! 对于只有两 ...
- 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 ...
- 【HDOJ】1031 Design T-Shirt
qsort直接排序. #include <stdio.h> #include <string.h> #include <stdlib.h> #define MAXN ...
- 最近点对问题 HDU Quoit Design 1007 分治法
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #i ...
- 8-7-Exercise
链接:第二次小练 这次是我们这组出的题目~我出了一道......B-Prison rearrangement,感觉有点复杂~不过其实题目想通了还是很简单的...... @荆红浅醉出的是A.C.D,@从 ...
- 【English】七、常见动词
一.动词: touch.hear.say.listen touch [tʌtʃ] 触摸 I touch the cat. They touch the elephant. hear [hɪr] 听到 ...
随机推荐
- IMDb Search
主要是一个搜索电影,显示电影信息的小程序,开发坏境是xcode7.0,swift2.0 创建HTTP请求连接并对连接格式化 了解NSURLSession类的使用方法 通过NSURLSession类的d ...
- Libcurl笔记二
一: multi与easy接口的不同处The multi interface offers several abilities that the easy interface doesn't. The ...
- 转:浅谈大型web系统架构
浅谈大型web系统架构 动态应用,是相对于网站静态内容而言,是指以c/c++.php.Java.perl..net等服务器端语言开发的网络应用软件,比如论坛.网络相册.交友.BLOG等常见应用.动态应 ...
- EF迁移
第一步是为上下文启用迁移Enable-Migrations 命令 Add-Migration AddBlogUrl 将根据自创建上次迁移以来您对模型所做的更改,为下一次迁移搭建基架. Update-D ...
- ajaxFileUpload - Post file and data together
jQuery.extend({ createUploadIframe: function(id, uri) { //create frame var frameId = 'jUploadFrame' ...
- Node.js 【使用npm安装一些包失败之笔记】
镜像使用方法(三种办法任意一种都能解决问题,建议使用第三种,将配置写死,下次用的时候配置还在): 1.通过config命令 npm config set registry https://regist ...
- sublime 设置localhost 2
最近sidebar用不了了,提示更新然后就自动卸载了: 研究了下其他方式实现: Sublime Text 2 Sublime Text 3 都可以使用: 菜单 --> Tools --> ...
- spark 1.3.0下的问题
1.在spark SQL的一个test中 无论是registerAsTable还是registerTempTable 都会有问题,经过查找各种资料,采用如下的方式: val sqlCon=new or ...
- C语言多线程编程
HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, DWORD dwStackSize, LPTHREAD_START_ROUT ...
- 快速编译Delphi XE3 项目工程组
Embarcadero 做了个好事.工程组可以直接使用 MSBuild 进行编译,让发布更简单.在Bin目录中 rsvars.bat 用于设置编译的环境变量,结合使用就可以顺利进行编译. call r ...