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. 24种设计模式--组合模式【Composite Pattern】

    大家在上学的时候应该都学过“数据结构”这门课程吧,还记得其中有一节叫“二叉树”吧,我们上学那会儿这一章节是必考内容,左子树,右子树,什么先序遍历后序遍历什么,重点就是二叉树的的遍历,我还记得当时老师就 ...

  2. PHP AOP

    看到一篇好文,果断收藏 点击打开链接http://www.cnblogs.com/afritxia2008/archive/2010/07/03/1770427.html

  3. web前端必须掌握的localStorage

    先自我介绍一下,本人男,27岁,单身,web前端程序员一枚,长期潜伏在幕后,只学不教(貔貅么?),其实主要是工作太忙了,每天忙到11点左右,没有时间写东西,洗洗就睡了.最近赶巧,后端那边出技术瓶颈了, ...

  4. 包管理器Bower使用手册之一

    包管理器Bower使用手册之一 作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs 一.Bower介绍 Bower是一个适合Web应用的包管理器,它擅长前端的 ...

  5. (转载)delphi 常用函数(数学)

    delphi 常用函数(数学) Delphi中怎么将实数取整? floor 和 ceil 是 math unit 里的函数,使用前要先 Uses Math.trunc 和 round 是 system ...

  6. raywenderlich-iOS设计模式Part 1/2【译】

    原文地址:http://www.raywenderlich.com/86477/introducing-ios-design-patterns-in-swift-part-1 Update 04/22 ...

  7. [swift] NSClassFromString 无法获得该类

    在写OC的时候需要用 NSClassFromString(classStringName)获得一个类,如果存在就用这个类型来声明一个对象, 但是在swift的时候却往往得不到这个类,为什么呢? 从截图 ...

  8. Xcode报错 - 1

    1. xcode在真机调试的时候出现"The identity used to sign the executable is no longer valid" 解析: 是由于.pr ...

  9. 支持HTML5 SqlLite的AndroidApp

    简介: 想要建立一个支持HTML5的Android App; 这个HTML5的程序需要使用本地存储,特别是sqllite; 用eclipse创建了一个app,这个app默认在res/layout建了两 ...

  10. avalon 中require.config源码分析

    /********************************************************************* * 配置系统 在系统运行的开始就需要读取系统中requir ...