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 ...
随机推荐
- OC-手动内存管理
一.为什么要进行内存管理 •移动设备的内存极其有限,每个app所能占用的内存是有限制的 • •下列行为都会增加一个app的内存占用 Ø创建一个OC对象 Ø定义一个变量 Ø调用一个函数或者方法 • •当 ...
- html页面布局 第8节
页面布局: <html> <head> <title>页面布局</title> <style type="text/css"& ...
- Splay tree
类别:二叉排序树 空间效率:O(n) 时间效率:O(log n)内完成插入.查找.删除操作 创造者:Daniel Sleator和Robert Tarjan 优点:每次查询会调整树的结构,使被查询频率 ...
- Linux网络应用编程之Packet Tracer安装及界面介绍
Packet Tracer入门 一,Packet Tracer介绍 packet tracer 是由Cisco公司发布的一个辅助学习工具,为学习思科网络课程的初学者去设计.配置.排除网络故障提供了网络 ...
- uploadify 上传文件出现HTTP 404错误
今天在使用jquery.uploadify.js上传文件的时候,出现HTTP 404错误,此错误在上传较小文件时不会出现,在上传一个50M左右文件时出现此错误,经过测试和日志查看发现,根本没有进入后台 ...
- HTML5中的Canvas
1.Canvas标签的宽高一定要设置在标签上或者采用js添加属性,如果用css去设置的话,会把画布被拉伸,相当于将默认的画布拉伸到指定位置.默认为300px*100px; <canvas wid ...
- Echart..js插件渲染报错 data.length<1?
问题 getJSON提交 返回数据正常,在传入参数进行序列化,渲染报表时报错 option.data.length < 1. 分析 1.可能情况一: . 可自己明明是getJSON()把渲染放 ...
- AppDomain(1)-AppDomainSetup
- Win7 + VS2015 + CMake3.6.1-GUI编译库
CMake生成Unicode版本VC工程 Just add this line in your top CMakeLists.txt file: add_definitions(-DUNICO ...
- 修改phpmyadmin上传文件大小限制
当你想将SQL语句,导入phpmyadmin 时,发现自己的sql语句文本大小 大于 phpmyadmin的课上传的文本大小. 默认phpmyadmin上传文件大小为2M,如果想要phpmyadmin ...