解题思路:

给出 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. Linux下安装 php-memcache 扩展

    需要的库:yum install -y libmemcached libmemcached-devel 下载:https://pecl.php.net/package/memcached 安装: un ...

  2. 悦享双节,Guitar Pro也来凑份热闹!

    光阴似箭,又是一个金秋的十月,祖国迎来了第68个生日,不同以往的是今年的中秋佳节与国庆假日重叠在一起了,这算不算是喜上加喜呢? 提到国庆人们的耳边总是会响起了一遍又一遍的国歌“起来,起来不愿做奴隶的人 ...

  3. 嵌入式平台选择:树莓派 or BeagleBone Black(BBB)

    原文链接: Michael Leonard 翻译: 极客范- 小道空空 译文链接: http://www.geekfan.net/5246/ 嵌入式平台选择:树莓派 or BeagleBone Bla ...

  4. Vue学习之路第六篇:v-on

    v-on指令用来触发页面事件的指令. <body> <div id="app"> <button v-on:click="show()&qu ...

  5. Node.js 指南(迁移到安全的Buffer构造函数)

    迁移到安全的Buffer构造函数 移植到Buffer.from()/Buffer.alloc() API. 概述 本指南介绍了如何迁移到安全的Buffer构造函数方法,迁移修复了以下弃用警告: 由于安 ...

  6. MVC、RPC、SOA、微服务架构之间的区别

    MVC.RPC.SOA.微服务架构之间的区别 一.MVC架构 其实MVC架构就是一个单体架构. 代表技术:Struts2.springMVC.Spring.Mybatis 等等. 二.RPC架构 RP ...

  7. Vue父子组件之间的通讯(学习笔记)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. DelayQueue延时队列示例

    介绍: DelayQueue是一个无界阻塞队列,只有在延迟期满时才能从中提取元素.该队列的头部是延迟期满后保存时间最长的Delayed 元素. 使用场景: 缓存系统的设计,缓存中的对象,超过了空闲时间 ...

  9. 洛谷——P3258 [JLOI2014]松鼠的新家

    https://www.luogu.org/problem/show?pid=3258 题目描述 松鼠的新家是一棵树,前几天刚刚装修了新家,新家有n个房间,并且有n-1根树枝连接,每个房间都可以相互到 ...

  10. 【POJ 2485】 Highways

    [POJ 2485] Highways 最小生成树模板 Prim #include using namespace std; int mp[501][501]; int dis[501]; bool ...