解题思路:

给出 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. Oprofile分析(android oprofile性能分析)

    一.内核支持: make menuconfig 1.评测菜单中启用 Oprofile ,在 .config 文件中设置?CONFIG_PROFILING=y?和?CONFIG_OPROFILE=y 2 ...

  2. 尝试实现bootstrap3网格系统

    这是一篇搁置了很久的博文,个人实现的关键代码如下: // 这是用sass实现的,只是大致实现了网格系统和offset的功能 $size_list: ( xs: 0, sm: 576, md: 992, ...

  3. node操作mysql插入数据异常,incorrect string value

    产生的原因 我在创建表的时候,并没有设定字符编码,所以,默认的字符编码是 latin1 在我插入数据的时候,我的一个字段name设定的是varchar(20) 其实,这时的编码就是 latin1 所以 ...

  4. C#操作IIS服务

    进入正题:先从使用角度来讲解IIS操作,然后再深入到具体的IIS服务底层原理. [1]前提掌握要点: (1).IIS到目前经历了四个版本分别为 IIS4.0 IIS5.0 IIS6.0 IIS7.0, ...

  5. windows 2008 中IIS7.0以上如何设置404错误页面

    404错误页面的设置,不仅仅可以提高用户体验度,从SEO方面考虑,也是非常重要的.今天,笔者在这里介绍一下在windows 2008下如何设置404错误页面. 注意:设置404有我这里介绍2种方式,推 ...

  6. JS 有一张0.0001米的纸,对折多少次可以达到珠穆朗玛峰的高度8848;

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. ajax第一天总结

    AJAX开发步骤 步一:创建AJAX异步对象,例如:createAJAX() 步二:准备发送异步请求,例如:ajax.open(method,url) 步三:如果是POST请求的话,一定要设置AJAX ...

  8. Day 03 知识点[python程序运行的方式、变量、注释、内存管理、数据类型]

    执行Python程序的两种方式 第一种:交互式,在cmd中运行 优点:调试程序方便,直接给出结果 缺点:无法保存,关掉cmd窗口数据就消失 第二种:命令行式通过cmd中输入Python3文本 优点:数 ...

  9. Java web课程学习之JSP

    JSP     jsp隐式对象:JSP隐式对象是JSP容器为每个页面提供的Java对象,开发者可以直接使用它们而不用显式声明.JSP隐式对象也被称为预定义变量. jsp脚本片段 l jsp脚本片段是指 ...

  10. 【HiJ1m】在NOIP2017前写过的有用的东西汇总

    http://www.cnblogs.com/Elfish/p/7544623.html 高级树状数组 http://www.cnblogs.com/Elfish/p/7554420.html BST ...