HDUOJ----(1031)Design T-Shirt
Design T-Shirt
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4370 Accepted Submission(s): 2124
Problem Description
Soon after he decided to design a T-shirt for our Algorithm Board on Free-City BBS, XKA found that he was trapped by all kinds of suggestions from everyone on the board. It is indeed a mission-impossible to have everybody perfectly satisfied. So he took a poll to collect people's opinions. Here are what he obtained: N people voted for M design elements (such as the ACM-ICPC logo, big names in computer science, well-known graphs, etc.). Everyone assigned each element a number of satisfaction. However, XKA can only put K (<=M) elements into his design. He needs you to pick for him the K elements such that the total number of satisfaction is maximized.
Input
The input consists of multiple test cases. For each case, the first line contains three positive integers N, M and K where N is the number of people, M is the number of design elements, and K is the number of elements XKA will put into his design. Then N lines follow, each contains M numbers. The j-th number in the i-th line represents the i-th person's satisfaction on the j-th element.
Output
For each test case, print in one line the indices of the K elements you would suggest XKA to take into consideration so that the total number of satisfaction is maximized. If there are more than one solutions, you must output the one with minimal indices. The indices start from 1 and must be printed in non-increasing order. There must be exactly one space between two adjacent indices, and no extra space at the end of the line.
Sample Input
3 6 4
2 2.5 5 1 3 4
5 1 3.5 2 2 2
1 1 1 1 1 10
3 3 2
1 2 3
2 3 1
3 1 2
Sample Output
6 5 3 1
2 1
Author
CHEN, Yue
Source
CYJJ's Funny Contest #1, Killing in Seconds
Recommend
几次排序就可以ac掉...没啥技术...水体
代码:
1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<climits>
5 #include<cstdlib>
6 #include<algorithm>
7 #include<vector>
8 using namespace std;
9
10 typedef struct Nod
11 {
12 int num;
13 float value;
14 }nod;
15 /*二级排序*/
16 int cmp(nod a,nod b)
17 {
18 if(a.value==b.value)
19 {
20 return a.num<b.num; //小到大
21 }
22 else
23 return a.value>b.value; //降序大到小
24 }
25
26 int Less(int a,int b)
27 {
28 return a>b; //降序大到小
29 }
30 int main()
31 {
32 int n,m,k,i;
33 float cnt;
34 while(scanf("%d %d %d",&n,&m,&k)!=EOF)
35 {
36 vector<nod>start(m);
37 vector<int>ans(k);
38 /*初始化*/
39 for(i=0;i<m;i++)
40 {
41 scanf("%f",&start[i].value);
42 start[i].num=i+1;
43 }
44 n--;
45 while(n--)
46 {
47 for(i=0;i<m;i++)
48 {
49 scanf("%f",&cnt);
50 start[i].value+=cnt;
51 }
52 }
53 sort(start.begin(),start.end(),cmp);
54 for(i=0;i<k;i++)
55 {
56 ans[i]=start[i].num;
57 }
58 sort(ans.begin(),ans.end(),Less);
59 printf("%d",ans[0]);
60 for(i=1;i<k;i++)
61 {
62 printf(" %d",ans[i]);
63 }
64 putchar(10);
65 }
66 return 0;
67 }
- scrapy回调函数传递参数
- python更新数据库脚本两种方法
- 使聊天机器人具有个性
- 遇到502错误,invalid request block size 解决方法
- python中json.loads,dumps,jsonify使用
- sqlalchemy和flask-sqlalchemy几种分页操作
- 一个 tflearn 情感分析小例子
- 前端js,后台python实现RSA非对称加密
- 运行mysql时,提示Table ‘performance_schema.session_variables’ doesn’t exist
- ODL应用开发之MD-SAL中级教程
- Sql参数是一个list的最佳实践
- MyBatis 配置输出日志,不输出SQL问题解决
- lombok让你提高代码整洁度的神器附教程及原理分析
- mvn编译的时候一个破错误,google只有3个结果maven : Failed to install metadata project Could not parse metadata maven-
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- crontab执行时间与系统时间不一致问题解决
- Linux内核设备驱动之proc文件系统笔记整理
- CentOS7.6系统下使用yum配置lnmp环境的方法
- Linux内核设备驱动之高级字符设备驱动笔记整理
- Linux使用scp命令进行文件远程拷贝详解
- Linux内核设备驱动之Linux内核模块加载机制笔记整理
- linux无损扩容的方法
- Linux内核设备驱动之内核的时间管理笔记整理
- 使用squid搭建http和https的代理服务器设置指南
- linux中gdb的入门使用教程
- Linux命令中Ctrl+z、Ctrl+c和Ctrl+d的区别和使用详解
- Linux lseek函数的使用详解
- Nginx出现500 Internal Server Error 错误的解决方案
- Linux常见基本命令与用法大全
- Navicat 环境测试 innodb 的默认行锁升级表锁