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 ...
随机推荐
- jQuery分析(3) - jQuery.fn.init
1.前言 上一篇jQuery分析(2)中了解了jQuery库的骨架实现原理,这就好比摇滚音乐,摇滚音乐不是某种音乐他就像一个音乐盒子,里面包含了各种不同的摇滚风格(山地.朋克.乡村.流行.硬摇.金属. ...
- 工具系列之Sublime Text 3 使用总结
1.Sublime Text 2/3如何支持中文GBK编码(解决中文乱码) Sublime Text默认是只支持UTF8的编码,所以有些时候,当我们打开GBK文件时候,文件内会出先部分的乱码,如下图 ...
- UVA 11464 Even Parity(部分枚举 递推)
Even Parity We have a grid of size N x N. Each cell of the grid initially contains a zero(0) or a on ...
- Google C++编程风格指南
作者:Hawstein 出处:http://hawstein.com/posts/google-cpp-style-guide.html 前言 越来越发现一致的编程风格的重要性,于是把Google的C ...
- [翻译][MVC 5 + EF 6] 3:排序、过滤、分页
原文:Sorting, Filtering, and Paging with the Entity Framework in an ASP.NET MVC Application 1.添加排序: 1. ...
- 微软AJAX解决方案
-------- 微软AJAX解决方案 (*) --------ASP.Net中内置的简化AJAX开发的控件UpdatePanel 放入ScriptManager,将要实现AJAX效果的控件放到Upd ...
- PHP - 《高性能php应用开发》学习笔记
一.基准测试 php网站优化最佳实践:优化前端(压缩js/css/images)--->程序优化(编码最佳实践.opcode缓存.变量/数据缓存)--->数据库.服务器调优-->操作 ...
- How to get Directory size in IsolatedStorage of Windows Phone 8 App
There is no API to get the total size of a specific directory in the isolated storage. Therefore, th ...
- Codeforces Round #336 (Div. 1) A - Chain Reaction
Chain Reaction 题意:有n(1 ≤ n ≤ 100 000) 个灯泡,每个灯泡有一个位置a以及向左照亮的范围b (0 <= a <= 1e6 ,1<= b <= ...
- Highchart :tooltip工具提示
Highcharts翻译系列之十六:tooltip工具提示tooltip工具提示 参数 描述 默认值 animation 启用或禁用提示的动画.这对大数据量的图表很有用 true background ...