UVa2521
理解:max 记录的是有大牌的个数 mid 是有中断 而造成的不确定 我理解是一个间断点以下的 数和一个间断点抵消 在前面没有间断的情况下 才能确定这张牌稳赢
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int num[1005];
int main()
{
int m,n;
int ct=1;
while(cin>>m>>n&&(n+m))
{
memset(num,0,sizeof(num));
for(int i=0; i<n; i++)
{
int temp;
cin>>temp;
num[temp]=1;
}
int max=0,mid=0;
for(int i=n*m;i>0;i--)
{
if(num[i]==1){
if(mid==0)max++;
else mid--;
}
else mid++;
}
printf("Case %d: %d\n",ct++,max);
}
}
UVa2521的更多相关文章
随机推荐
- NYOJ 762
容斥原理 http://blog.csdn.net/shiren_bod/article/details/5787722
- Nginx 日志中记录cookie
在http节点下添加 log_format mai2 '$remote_addr - $remote_user [$time_local] "$request" ' '$statu ...
- HttpClient
Http协议的重要性相信不用我多说了,HttpClient相比传统JDK自带的URLConnection,增加了易用性和灵活性(具体区别,日后我们再讨论),它不仅是客户端发送Http请求变得容易,而且 ...
- LeetCode:Merge k Sorted Lists
题目链接 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexi ...
- BAD APPLE C++控制台程序
使用C++语言编写,如果想改成C语言,手动以GetProcAddress的方式来调用相关函数即可. #include <windows.h> #include <mmsystem.h ...
- LeetCode-70-Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- .bat文件和Jar包的生成及运行
.bat文件和Jar包的生成及运行 1.Jar包简单介绍 Jar包是Java中所特有的一种压缩文档,有点类似于zip包,区别在于Jar包中有一个META-INF\MANIFEST.MF文件(在生成Ja ...
- 51Nod-1136 欧拉函数
51Nod: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1136 1136 欧拉函数 基准时间限制:1 秒 空间限制: ...
- RecyclerView的使用(四)
前面我们已经实现了RecyclerView的大部分功能了,但是有个很明显的缺陷-------没有点击效果!这就坑爹了 ListView自带点击效果好嘛!连这个都要自己定义.... 话不多说,下面就来为 ...
- [转]Struts2.3.16.1+Hibernate4.3.4+Spring4.0.2 框架整合
原文地址:http://blog.csdn.net/ycb1689/article/details/22928519 最新版Struts2+Hibernate+Spring整合 目前为止三大框架最新版 ...