http://acm.hdu.edu.cn/showproblem.php?pid=1338

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 <bits/stdc++.h>
using namespace std; int N, M;
int num[55]; int main() {
int Case = 0;
while(~scanf("%d%d", &N, &M)) {
Case ++;
if(!N && !M) break;
for(int i = 1; i <= M; i ++) {
scanf("%d", &num[i]);
} int maxx = N * M;
int cnt = 0;
sort(num + 1, num + 1 + M);
for(int i = M; i >= 1; i --) {
if(num[i] >= maxx) {
cnt ++;
maxx --;
}
else maxx -= 2;
}
printf("Case %d: %d\n", Case, cnt);
}
return 0;
}

  

HDU 1338 Game Prediction的更多相关文章

  1. HDU 1338 Game Prediction【贪心】

    解题思路: 给出 n  m 牌的号码是从1到n*m 你手里的牌的号码是1到n*m之间的任意n个数,每张牌都只有一张,问你至少赢多少次 可以转化为你最多输max次,那么至少赢n-max次 而最多输max ...

  2. HDU 5923 Prediction

    这题是2016 CCPC 东北四省赛的B题, 其实很简单. 现场想到的就是正解, 只是在合并两个并查集这个问题上没想清楚. 做法 并查集合并 + 归并 对每个节点 \(u\), 将 \(u\) 到根的 ...

  3. HDU 5923 Prediction(2016 CCPC东北地区大学生程序设计竞赛 Problem B,并查集)

    题目链接  2016 CCPC东北地区大学生程序设计竞赛 B题 题意  给定一个无向图和一棵树,树上的每个结点对应无向图中的一条边,现在给出$q$个询问, 每次选定树中的一个点集,然后真正被选上的是这 ...

  4. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  5. hdu 5895 广义Fibonacci数列

    Mathematician QSC Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  6. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  7. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  8. HDU 6153 A Secret 套路,求解前缀在本串中出现的次数

    http://acm.hdu.edu.cn/showproblem.php?pid=6153 首先相当于翻转两个串,然后求s2前缀在s1中出现的次数. 这是一个套路啦 首先把两个串结合起来,中间加一个 ...

  9. HDOJ 2111. Saving HDU 贪心 结构体排序

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

随机推荐

  1. Myeclipse项目移植到eclipse

    注意: 针对java web项目(项目图标上有小地球的标志,说明这是个Web项目) 1. 首先导入项目到eclipse里,如下图: 2.需要把项目结构给调一下,在项目上右键-->Properti ...

  2. jQuery-qrcode.js 生成带Logo 的二维码

    引入文件  jQuery-qrcode.js 地址:https://blog-static.cnblogs.com/files/kitty-blog/jquery-qrcode.js https:// ...

  3. python字符串,数组操作

    今天倒是学到了很多知识,了解了python的基本数组,以及可变类型和不可变类型,还有元组,列表,字典等等的用法 然后作业如下 其中在做往list列表加东西时候遇到了小毛病,用户从控制台输入的是一个字符 ...

  4. 4.《python自省指南》学习

    前言   前面几篇博客我都是通过python自省来分析代码并试图得出结论.当然,仅仅通过自省能解决的问题有限,但遇到问题还是不自主的去用这个功能,觉得对于认识代码的含义还是有一定帮助的.而这些自省的知 ...

  5. linux网络服务实验

    1.设置window IP地址为192.168.3.XX,掩码24位. 2.设置Linux IP地址为192.168.3.YY,掩码24位.window与Linux互相ping通. 3.在linux中 ...

  6. HDU 1495 非常可乐 (只是转了个弯的广搜题)

    N - 非常可乐 =========================================================================================== ...

  7. 小米Pro 15.6 系统重装记录

    参考链接:http://bbs.xiaomi.cn/t-14321262,主要是miui论坛和小米社区的一位同学的教程,. 这位同学是针对12.5和13.3的版本做的教程,15.6和之前的版本有一小点 ...

  8. 转MySQL详解--索引

    写在前面:索引对查询的速度有着至关重要的影响,理解索引也是进行数据库性能调优的起点.考虑如下情况,假设数据库中一个表有10^6条记录,DBMS的页面大小为4K,并存储100条记录.如果没有索引,查询将 ...

  9. This content database has a schema version which is not supported in this farm.

          I want to move the website to another server. The new server has reinstall Sharepoint2013 serv ...

  10. [转]Android UI 自动化测试

    介绍 Android测试支持库包含UI自动化模块,它可以对Android应用进行自动黑盒测试.在API Level 18中引入了自动化模块,它允许开发者在组成应用UI的控件上模仿用户行为. 在这个教程 ...