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

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
 
水题,结构题二级排序,在对编号进行逆序排序
 
#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的更多相关文章

  1. 【English】七、常见动词

    一.动词: touch.hear.say.listen touch [tʌtʃ] 触摸 I touch the cat. They touch the elephant. hear  [hɪr] 听到 ...

  2. 带你实现开发者头条APP(四)---首页优化(加入design包)

    title: 带你实现开发者头条APP(四)---首页优化(加入design包) tags: design,Toolbar,TabLayout,RecyclerView grammar_cjkRuby ...

  3. 【知识必备】一文让你搞懂design设计的CoordinatorLayout和AppbarLayout联动,让Design设计更简单~

    一.写在前面 其实博主在之前已经对design包的各个控件都做了博文说明,无奈个人觉得理解不够深入,所以有了这篇更加深入的介绍,希望各位看官拍砖~ 二.从是什么开始 1.首先我们得知道Coordina ...

  4. Android Material Design之 NavigationView侧滑界面自定义 随笔

    一.侧滑界面Menu自定义: 在menu文件夹下新建activity_main_drawer.xml文件,自定义标题和icon: <?xml version="1.0" en ...

  5. Material Design Reveal effect(揭示效果) 你可能见过但是叫不出名字的小效果

    Material Design Reveal effect(揭示效果) 你可能见过但是叫不出名字的小效果 前言: 每次写之前都会来一段(废)话.{心塞...} Google Play首页两个tab背景 ...

  6. 使用Design包实现QQ动画侧滑效果和滑动菜单导航

    Google在2015的IO大会上,给我们带来了更加详细的Material Design设计规范,同时,也给我们带来了全新的Android Design Support Library,在这个supp ...

  7. 安卓Design包下的TextInputLayout和FloatingActionButton的简单使用

    终于介绍到Design包的最后的东西了. 也很简单,一个是TextInputLayout. TextInputLayout作为一个父容器,包含一个新的EditText,可以给EditText添加意想不 ...

  8. 安卓Design包之AppBar和Toolbar的联用

    前面讲了Design包的的CoordinatorLayout和SnackBar的混用,现在继续理解Design包的AppBar; AppBarLayout跟它的名字一样,把容器类的组件全部作为AppB ...

  9. 安卓Design包之超强控件CoordinatorLayout与SnackBar的简单使用

    在前面的Design中,学习使用了TabLayout,NavigationView与DrawerLayout实现的神奇效果,今天就带来本次Design包中我认为最有意义的控件CoordinatorLa ...

  10. 安卓Design之NavigationView的使用

    前面讲解了Design包下的TabLayout的使用,下面将带来NavagationView和DrawLayout以及toolbar的联动. 项目已经同步至:https://github.com/na ...

随机推荐

  1. jsonp调用webapi和mvc

    webapi代码如下: public string Get(int id) { var callback = HttpContext.Current.Request["callback&qu ...

  2. mysql笔记之主从切换

    一. 正常切换 1)从服务器检查SHOW PROCESSLIST语句的输出,直到你看到Has read all relaylogwaiting for the slave I/O thread to ...

  3. 增加Swap内存

    增加512M Swap内存 #首先先建立一个分区,采用dd命令如下:dd if=/dev/zero of=/home/swap bs=1024 count=524288#(1个block为1K,512 ...

  4. IniParse解析类

    说明 iniParse这个类是一个解析ini文件的类,他的功能和Windows下GetPrivateProfileString的功能一样,可以很方便的保存读取配置. 当然他不是只有GetPrivate ...

  5. 利用php获取图片完整Exif信息类 获取图片详细完整信息类

    <?php /** * @Author: TonyLevid * @Copyright: TonyLevid.com * @Name: Image Exif Class * @Version: ...

  6. 易买网(注册Ajax讲解)

    关于注册(用到Ajax) 运用onblur进行时时刷新 创建所需用的Servlet 好了 Ajax其实不是很难  如果还是不懂可以私信我呦-^^-!

  7. 使用原生js与jQuery分别实现一个简单的tab页签

    tab页签通常适用于空间有限而内容较多同时兼顾页面美观度不给用户一种信息过量视觉疲劳的情形.使用面非常广,下面我们用两种方法简单实现之. 首先,构建页面元素.页签的可点击部分我们通常用列表来承载,包括 ...

  8. 分享自己动手弄的基于Rime的新世纪五笔输入法码表

    实验室新搞了一台iMac,没有支持新世纪的码表的中文输入法啊.搜索半天大家推荐用Rime(鼠须管)来挂接新世纪码表.不知道还有没有其它支持外挂码表的Mac版输入法,暂时只有搞这个了.看了一下别人已经做 ...

  9. 【C#】动态加载dll程序集

    原文:http://www.cnblogs.com/bomo/archive/2013/03/01/2938165.html 很多时候我们需要用到引用其他程序集,有些程序集是.Net生成的,可以支持反 ...

  10. 致命错误: Python.h:没有那个文件或目录

    In file included from greenlet.c:5:0: greenlet.h:8:20: 致命错误: Python.h:没有那个文件或目录 编译中断. error: Setup s ...