Design T-Shirt
Design T-Shirt
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4273 Accepted Submission(s): 2076
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 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.
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.
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
2 1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct {
float sa;
int nu;
}Node;
Node logo[];
int temp[]; int comp1(const void *a,const void *b)
{
Node *p1,*p2;
p1 = (Node *)a;
p2 = (Node *)b;
if(p1->sa!=p2->sa)
return p2->sa-p1->sa;
return p1->nu-p2->nu;
} int comp2(const void *a,const void *b)
{
return *(int*)b-*(int *)a;
}
void init(int n)
{
int i;
for(i =; i < n; i ++)
{
logo[i].sa = 0.;
logo[i].nu = i+;
}
} int main()
{
int i,j,n,m,k;
float a;
while(~scanf("%d%d%d",&n,&m,&k))
{
memset(temp,,sizeof(temp[]));
init(m);
for(i =;i < n; i ++)
{
for(j =; j < m; j ++)
{
scanf("%f",&a);
logo[j].sa += a;
}
}
qsort(logo,m,sizeof(logo[]),comp1);
for(i =;i < k; i ++)
temp[i] = logo[i].nu;
qsort(temp,k,sizeof(temp[]),comp2);
for(i =;i < k-; i ++)
printf("%d ",temp[i]);
printf("%d\n",temp[i]);
}
return;
}
Design T-Shirt的更多相关文章
- 【English】七、常见动词
一.动词: touch.hear.say.listen touch [tʌtʃ] 触摸 I touch the cat. They touch the elephant. hear [hɪr] 听到 ...
- 带你实现开发者头条APP(四)---首页优化(加入design包)
title: 带你实现开发者头条APP(四)---首页优化(加入design包) tags: design,Toolbar,TabLayout,RecyclerView grammar_cjkRuby ...
- 【知识必备】一文让你搞懂design设计的CoordinatorLayout和AppbarLayout联动,让Design设计更简单~
一.写在前面 其实博主在之前已经对design包的各个控件都做了博文说明,无奈个人觉得理解不够深入,所以有了这篇更加深入的介绍,希望各位看官拍砖~ 二.从是什么开始 1.首先我们得知道Coordina ...
- Android Material Design之 NavigationView侧滑界面自定义 随笔
一.侧滑界面Menu自定义: 在menu文件夹下新建activity_main_drawer.xml文件,自定义标题和icon: <?xml version="1.0" en ...
- Material Design Reveal effect(揭示效果) 你可能见过但是叫不出名字的小效果
Material Design Reveal effect(揭示效果) 你可能见过但是叫不出名字的小效果 前言: 每次写之前都会来一段(废)话.{心塞...} Google Play首页两个tab背景 ...
- 使用Design包实现QQ动画侧滑效果和滑动菜单导航
Google在2015的IO大会上,给我们带来了更加详细的Material Design设计规范,同时,也给我们带来了全新的Android Design Support Library,在这个supp ...
- 安卓Design包下的TextInputLayout和FloatingActionButton的简单使用
终于介绍到Design包的最后的东西了. 也很简单,一个是TextInputLayout. TextInputLayout作为一个父容器,包含一个新的EditText,可以给EditText添加意想不 ...
- 安卓Design包之AppBar和Toolbar的联用
前面讲了Design包的的CoordinatorLayout和SnackBar的混用,现在继续理解Design包的AppBar; AppBarLayout跟它的名字一样,把容器类的组件全部作为AppB ...
- 安卓Design包之超强控件CoordinatorLayout与SnackBar的简单使用
在前面的Design中,学习使用了TabLayout,NavigationView与DrawerLayout实现的神奇效果,今天就带来本次Design包中我认为最有意义的控件CoordinatorLa ...
- 安卓Design之NavigationView的使用
前面讲解了Design包下的TabLayout的使用,下面将带来NavagationView和DrawLayout以及toolbar的联动. 项目已经同步至:https://github.com/na ...
随机推荐
- 反射 介绍System.Type类
本节先介绍system.Type类,通过这个类可以访问关于任何数据类型的信息. 1. system.Type类以前把Type看作一个类,但它实际上是一个抽象的基类.只要实例化了一个Type对象,实际上 ...
- 记:mysql 连接超时解决办法
错误描述:Timeout in IO operation 原连接字符串为:Server=182.180.50.118;port=3306;Database=test;Uid=root;Pwd=123; ...
- Java实战之01Struts2-02配置文件
三.Struts2的配置文件 1.加载时机: 当应用被tomcat加载的时候,struts2的配置文件就已经被加载过了. 2.加载顺序 顺序 配置文件名 所在位置 说明 1 default.prope ...
- 在ARM Linux 使用 Valgrind
Linux valgrind 移植到ARM-Linux 一.Cross-Compile/交叉编译 (1)下载及解压Valgrind-3.11 (2)修改confirure 将armv7*)修改为ar ...
- 如何设置 font-family 比较好以及字体的中英文名
如何设置 font-family 比较好? 如果设置为font-family: Arial, "微软雅黑","宋体"; 是不是英文都会使用Arial字体,而中文 ...
- datatable的数据转置
没有具体测试过,5w条数据在i5机器上大概是1.3~2s左右,但是个人感觉就是在处理数据库的分页或者是写条件的时候会有一些麻烦,不如使用数据库分页! 但是这种方法不失为一种思路 private voi ...
- Cocos2d-x课程大纲/学习路线
Cocos2d-x课程大纲/学习路线 这是什么? 这个一个Cocos2d-x技术路线的课程大纲/学习大纲. 你能用它做什么? 如果你是找工作的人, 利用本大纲, 你可以学习Cocos2d-x, 做一个 ...
- Java源代码分析与生成
源代码分析:可使用ANTLRANTLR是开源的语法分析器,可以用来构造自己的语言,或者对现有的语言进行语法分析. JavaParser 对Java代码进行分析 CodeModel 用于生成Java代码 ...
- Sumbline编译Less
Less教程 Sublime Text 2的Less2Css插件介绍与安装 网址 http://fdream.net/blog/article/783.aspx 如果出现node.exe不是内部命令的 ...
- [記錄用]python py2app 檔案批次重新命名
demo.py 主要作用為 將同目錄下 *.mp4 檔案批次重新命名 例如: aaa001.mp4 ---重新命名為--> 001.mp4 aaa002.mp4 ---重新命名為--> 0 ...