解题思路:

给出 n  m 牌的号码是从1到n*m 你手里的牌的号码是1到n*m之间的任意n个数,每张牌都只有一张,问你至少赢多少次

可以转化为你最多输max次,那么至少赢n-max次 而最多输max次,则是对方最多赢max次,则用对方的最小的牌去依次比较你手中的牌(按照升序排),如果找到有比它小的,则对方赢一次 依次循环直到遍历完对方的牌。

Game Prediction

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 818    Accepted Submission(s): 453

Problem Description
Suppose there are M people, including you, playing a special card game. At the beginning, each player receives N cards. The pip of a card is a positive integer which is at most N*M. And there are no two cards with the same pip. During a round, each player chooses one card to compare with others. The player whose card with the biggest pip wins the round, and then the next round begins. After N rounds, when all the cards of each player have been chosen, the player who has won the most rounds is the winner of the game. Given your cards received at the beginning, write a program to tell the  maximal number of rounds that you may at least win during the whole  game.
 
Input
The input consists of several test cases. The first  line of each case contains two integers m (2 <= m <= 20) and n (1 <= n  <= 50), representing the number of players and the number of cards each  player receives at the beginning of the game, respectively. This followed by a  line with n positive integers, representing the pips of cards you received at  the beginning. Then a blank line follows to separate the cases. The  input is terminated by a line with two zeros.
 
Output
For each test case, output a line consisting of the  test case number followed by the number of rounds you will at least win during  the game.
 
Sample Input
2 5 1 7 2 10 9 6 11 62 63 54 66 65 61 57 56 50 53 48 0 0
 
Sample Output
Case 1: 2 Case 2: 4
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[1010],b[1010],used[1010];
int main()
{
int n,m,i,j,sum,flag=1;
while(scanf("%d %d",&m,&n)!=EOF&&(n||m))
{
sum=0;
memset(a,1,sizeof(a));
memset(used,1,sizeof(used));
for(i=1;i<=n;i++)
{
scanf("%d",&b[i]);
a[b[i]]=0;
}
sort(b,b+n); for(i=1;i<=n*m;i++)
{
if(a[i])
{
for(j=1;j<=n;j++)
{
if(i>b[j]&&used[j])
{
sum++;
used[j]=0;
break;
}
}
}
}
printf("Case %d: %d\n",flag,n-sum);
flag++;
}
}

  

HDU 1338 Game Prediction【贪心】的更多相关文章

  1. HDU 1338 Game Prediction

    http://acm.hdu.edu.cn/showproblem.php?pid=1338 Problem Description Suppose there are M people, inclu ...

  2. HDU 4442 Physical Examination(贪心)

    HDU 4442 Physical Examination(贪心) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=4442 Descripti ...

  3. HDU 5835 Danganronpa (贪心)

    Danganronpa 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5835 Description Chisa Yukizome works as ...

  4. HDU 5821 Ball (贪心)

    Ball 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5821 Description ZZX has a sequence of boxes nu ...

  5. hdu 4004 (二分加贪心) 青蛙过河

    题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4004 题目意思是青蛙要过河,现在给你河的宽度,河中石头的个数(青蛙要从石头上跳过河,这些石头都是在垂 ...

  6. Saving HDU(hdu2111,贪心)

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. HDU 4714 Tree2cycle:贪心

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4714 题意: 给你一棵树,添加和删除一条边的代价都是1.问你将这棵树变成一个环的最小代价. 题解: 贪 ...

  8. HDU 5303 Delicious Apples (贪心 枚举 好题)

    Delicious Apples Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Other ...

  9. HDU 5976 Detachment 【贪心】 (2016ACM/ICPC亚洲区大连站)

    Detachment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

随机推荐

  1. sql获得某个时间段的数据

    CONVERT(Date, 时间字符串变量 ) between CONVERT(Date,'2015/2/10') and CONVERT(Date,'2015-3-10')

  2. HTML文档 html,html5,css,css3

    HTML 各种标签及简单应用: http://www.w3school.com.cn 1 <p><p> 2 <br/> 3 <hr/>横线 4 < ...

  3. Android GreenDao 使用教程

    上一篇 总结了grendao 环境搭建以及简单的增删查改,接下来将全面解析框架的使用,基于上篇的orm模型(Note)数据库讲解 GreenDao的插入: 插入的方式有很多: daoSession.g ...

  4. StatusBarUtils工具类

    import android.app.Activity; import android.app.Dialog; import android.content.Context; import andro ...

  5. 为什么Arduino独占鳌头并站稳脚跟?

    出处: http://bbs.dfrobot.com.cn/thread-793-1-1.html 为什么Arduino独占鳌头并站稳脚跟? 每个月,我都会在<Make>杂志上发表几篇社论 ...

  6. webpack实战---安装操作

    什么是webpack? 他有什么优点?     首先对于很多刚接触webpack人来说,肯定会问webpack是什么?它有什么优点?我们为什么要使用它?     Webpack是前端一个工具,可以让各 ...

  7. jvm 虚拟机参数_新生代内存分配

    1.参数 -Xmn 设置新生代的大小,设置一个比较大的新生代会减少老年代的大小,这个参数对系统性能以及 GC 行为影响很大,新生代大小一般设置为真个堆内存的1/3到1/4 -XX:SurvivorRa ...

  8. SQL SERVER-NULL

    SQL SERVER判断NULL的函数 ISNULL().NVL().IFNULL() 和 COALESCE() 函数 来自为知笔记(Wiz)

  9. spring mvc拦截器interceptor

    1.  SpringMVC 中的Interceptor 拦截器也是相当重要和相当有用的,它的主要作用是拦截用户的请求并进行相应的处理.比如通过它来进行权限验证,或者是来判断用户是否登陆,或者是像123 ...

  10. SQL学习之使用order by 依照指定顺序排序或自己定义顺序排序

    我们通常须要依据客户需求对于查询出来的结果给客户提供自己定义的排序方式,那么我们通常sql须要实现方式都有哪些,參考很多其它资料总结例如以下(不完好的和错误望大家指出): 一.假设我们仅仅是对于在某个 ...