解题思路:

给出 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. Java 系列之spring学习--springmvc注解方式(五)

    一.springmvc注解方式 注解方式使用的更多,更加灵活.在上一篇的博客的基础上修改springmvc-servlet.xml配置文件. <?xml version="1.0&qu ...

  2. Web前端必须规避的8个误区

    现在,有越来越多所谓的“教程”来帮助我们提高网站的易用性.下面收集了一些在Web开发中容易出错和被忽略的小问题,并且提供了参考的解决方案,以便于帮助Web开发者更好的完善网站. 通过避免下面这些小错误 ...

  3. ndis6 how to drop packets

    In ndis6 how to drop packets? in FilterSendNetBufferLists: FILTER_RELEASE_LOCK(&pFilter->Lock ...

  4. MeayunDB-高性能分布式内存数据库

    MeayunDB(www.meayun.com)是一款分布式的NoSQL列式内存数据库,由C#编写,主要为高性能,高并发,高可伸缩及大数据系统提供技术解决方案.基于MeayunDB,可以简单,快速的构 ...

  5. OpenCV3 安装

    Opencv 安装 本文主要说明了在ubuntu上通过源码安装Opencv3,包含各种独立接口.具体可以参照LearnOpencv: https://www.learnopencv.com/insta ...

  6. 如何在使用layer.prompt在输入值为空的情况下点击确定继续执行逻辑?

    突然发现在使用LayUI时,用到弹出层layer.prompt时,如果文本框输入值是空的话点击确定没有反应,不能向下执行. 但是我又需要在这种情况下去继续执行判断或逻辑时该怎么做?? 示例:原代码如下 ...

  7. Use gdb attach pid and debug it

  8. python matplotlib数据可视化

    #基于python3 Matplotlib构建的3D图形: 使用pycharm的小伙伴把sciview给关掉: 因为sciview显示的是png图片.3d图形一般我们都需要拖拖拽拽的. 参见: htt ...

  9. HDU 1047 Integer Inquiry( 高精度加法水 )

    链接:传送门 思路:高精度水题 /************************************************************************* > File ...

  10. [读书笔记] Python数据分析 (一) 准备工作

    1. python中数据结构:矩阵,数组,数据框,通过关键列相互联系的多个表(SQL主键,外键),时间序列 2. python 解释型语言,程序员时间和CPU时间衡量,高频交易系统 3. 全局解释器锁 ...