解题思路:

给出 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. Custom Hosting in IIS/WAS

    常常需要与宿主实例进行交互.这对于使用自托管的方式是不可或缺的.当使用IIS或WAS时,不能直接访问宿主.为了克服这个障碍,WCF提供了一个宿主工厂.在.svc文件中使用Factory标签,使用此工厂 ...

  2. here.less

    <html><head><title>Test Less</title><link rel="stylesheet/less" ...

  3. Python中int,bool,str,格式化,少量is,已经for循环练习

    1.整数 ​ 十进制转化为二进制 ​ xxx.bit_length(). #求十进制数转化成二进制时所占用的位数 2.布尔值 ​ bool # 布尔值 - - 用于条件使用 ​ True 真 ​ Fa ...

  4. mongodb配置文件详解

    logpath=/app/mongo/mongolog/mongo.log dbpath=/app/mongo/mongodata verbose = true #vvvv = true #此项会产生 ...

  5. selenim

    一.安装selenium Pip install selenium==2.53.1    (稳定版) 下载火狐浏览器35.0.1  http://dl.pconline.com.cn/download ...

  6. Laravel 5.5 项目安装报错

    错误一. [Composer\Exception\NoSslException] The openssl extension is required for SSL/TLS protection bu ...

  7. css鼠标滑过出现文字效果

    模仿淘宝上鼠标移动到商品图片时,出现的文字效果. 1.效果图                                鼠标移动到粉红色的区域,则出现黄色部分. 2.代码 <!DOCTYPE ...

  8. Element源码阅读(2)

    一.element中的指令 在input-number组件中, 用到一个v-repeat-click指令, 主要用于input-number组件的重复点击效果.具体实现在directives中的rep ...

  9. 六、利用frp穿透连接内网的linx系统和windows系统

    服务端的配置 # frps.ini [common] bind_port = 7000 说明:防火墙放行该端口 启动:./frps -c ./frps.ini 后台启动:nohup ./frps -c ...

  10. vue解决跨域问题

    vue解决跨域问题 vue跨域解决方法和小总结 vue项目中,前端与后台进行数据请求或者提交的时候,如果后台没有设置跨域,前端本地调试代码的时候就会报“No 'Access-Control-Allow ...