HDU 1338 Game Prediction
http://acm.hdu.edu.cn/showproblem.php?pid=1338
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.
The input is terminated by a line with two zeros.
#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的更多相关文章
- HDU 1338 Game Prediction【贪心】
解题思路: 给出 n m 牌的号码是从1到n*m 你手里的牌的号码是1到n*m之间的任意n个数,每张牌都只有一张,问你至少赢多少次 可以转化为你最多输max次,那么至少赢n-max次 而最多输max ...
- HDU 5923 Prediction
这题是2016 CCPC 东北四省赛的B题, 其实很简单. 现场想到的就是正解, 只是在合并两个并查集这个问题上没想清楚. 做法 并查集合并 + 归并 对每个节点 \(u\), 将 \(u\) 到根的 ...
- HDU 5923 Prediction(2016 CCPC东北地区大学生程序设计竞赛 Problem B,并查集)
题目链接 2016 CCPC东北地区大学生程序设计竞赛 B题 题意 给定一个无向图和一棵树,树上的每个结点对应无向图中的一条边,现在给出$q$个询问, 每次选定树中的一个点集,然后真正被选上的是这 ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- hdu 5895 广义Fibonacci数列
Mathematician QSC Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Othe ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- HDU 6153 A Secret 套路,求解前缀在本串中出现的次数
http://acm.hdu.edu.cn/showproblem.php?pid=6153 首先相当于翻转两个串,然后求s2前缀在s1中出现的次数. 这是一个套路啦 首先把两个串结合起来,中间加一个 ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
随机推荐
- SQLSERVER SQL性能优化
1.选择最有效率的表名顺序(只在基于规则的优化器中有效) SQLSERVER的解析器按照从右到左的顺序处理FROM子句中的表名,因此FROM子句中写在最后的表(基础表driving ta ...
- 有个数组 我现在需要把数组里面的值按照n个一组,赋予一个新的数组
有个数组 我现在需要把数组里面的值按照七个一组,赋予一个新的数组
- swap, 不用临时变量如何做到交换a与b
固定思维通常是需要一个临时变量temp,如果没有这个临时变量呢,其实也不复杂,:) inline void swap(int &a, int &b) /*C用指针吧*/ { a = a ...
- CentOS7 minimal 没有netstat命令
在CentOS 7 minimal中使用netstat 时,发现显示如下,明显没有了netstat 命令 [root@localhost ~]# netstat -a -bash: netstat: ...
- Mysql 查看连接数,状态,最大并发数
MySQL: ERROR 1040: Too many connections”的异常情况,造成这种情况的一种原因是访问量过高,MySQL服务器抗不住,这个时候就要考虑增加从服务器分散读压力:另一种原 ...
- hadoop生态搭建(3节点)-01.基础配置
# 基础配置# ==================================================================node1 vi /etc/hostname nod ...
- STM32CubeMx配置SPI注意的一个问题
这样配置SPI引脚 然后这样配置SPI参数 生成立这样的配置代码 /* SPI2 init function */static void MX_SPI2_Init(void){ /* SPI2 par ...
- python继续函数-练习(2017-8-3)
写函数,计算传入字符串中[数字].[字母].[空格] 以及 [其他]的个数 def detection(p): intcount = 0 strcount = 0 othercount = 0 spa ...
- u-boot.bin生成过程分析
ELF格式“u-boot”文件的生成规则如下,下面对应Makefile的执行过程分别分析各个依赖. $(obj)u-boot: depend version $(SUBDIRS) $(OBJS) $( ...
- C++常量(const)的使用
#include <iostream> using namespace std; class MyClass { public: int GetValue() const ; int Ge ...