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] 听到 ...
随机推荐
- ASP.NET实现折线图的绘制
用到.Net中绘图类,实现折线图的绘制,生成图片,在页面的显示,代码如下: /// <summary> /// 获取数据 /// strChartName:图名称: /// yName:纵 ...
- swift基础知识学习
用let来声明常量,用var来声明变量 声明变量: var x = 0.0, y = 0.0, z = 0.0 var welcomeMessage: String 常量和变量的命名 你可以用任何 ...
- java新手笔记33 多线程、客户端、服务器
1.Mouse package com.yfs.javase; public class Mouse { private int index = 1; private boolean isLive = ...
- javascript 笔记——setTimeout的参数问题
setTimeout("xxx",500) 双引号中的作用域不捕捉局部变量,因此会报错误 如果你需要在双引号中可以在外部定义一个变量 var now; window.onload ...
- 基数排序(RadixSort)
1 基数排序的特点是研究多个关键字key,且多个key之间有权重之分, 或者可把单个key建模为含有多个key的排序 而计数排序.桶排序始终只有个一个key,或者说围绕着一个比较规则 Ex:比较 ...
- ECSSHOP表结构
ECSSHOP表结构 -- 表的结构 `ecs_account_log`CREATE TABLE IF NOT EXISTS `ecs_account_log` (`log_id` mediumint ...
- Qt模拟C#的File类对文件进行操作
其实只是QT菜鸟为了练习而搞出来的 文件头: #include <QFile> #include <QString> #include <iostream> #in ...
- Media Queries——媒体类型
媒体类型(Media Type)在CSS2中是一个常见的属性,也是一个非常有用的属性,可以通过媒体类型对不同的设备指定不同的样式. 在CSS2中常碰到的就是all(全部).screen(屏幕).pri ...
- Building microservices with Spring Cloud and Netflix OSS, part 2
In Part 1 we used core components in Spring Cloud and Netflix OSS, i.e. Eureka, Ribbon and Zuul, to ...
- php无极分类
<?php date_default_timezone_set('PRC'); header('Content-type:text/html;charset=UTF-8'); /* $a_lis ...