PAT1051. Pop Sequence (25)
#include <iostream>
#include <stack>
using namespace std;
int sizeMax,n,k;
stack<int> sta;
int queueNum;
int num;
int j;int flag=0;
int main(){
cin>>sizeMax>>n>>k;
while(k--){
while(!sta.empty()){sta.pop();}
queueNum=1;
flag=0;
for(int i=0;i<n;i++){
cin>>num;
if(flag){continue;}
if(num>queueNum){
for(j=queueNum;j<num;j++){
sta.push(j);
}
if(sta.size()>=sizeMax){
flag=1;
continue;
}
queueNum=num+1;
}else if(num<queueNum){
int top=sta.top();
if(top!=num){
flag=1;
continue;
}
sta.pop();
}else{
queueNum++;
}
}
if(flag){
cout<<"NO"<<endl;
}else{
cout<<"YES"<<endl;
}
}
return 0;
}
PAT1051. Pop Sequence (25)的更多相关文章
- PAT 解题报告 1051. Pop Sequence (25)
		1051. Pop Sequence (25) Given a stack which can keep M numbers at most. Push N numbers in the order ... 
- PAT1051:Pop Sequence
		1051. Pop Sequence (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a ... 
- pat02-线性结构4. Pop Sequence (25)
		02-线性结构4. Pop Sequence (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue Given ... 
- PTA 02-线性结构4 Pop Sequence   (25分)
		题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/665 5-3 Pop Sequence (25分) Given a stack wh ... 
- PAT 甲级 1051 Pop Sequence (25 分)(模拟栈,较简单)
		1051 Pop Sequence (25 分) Given a stack which can keep M numbers at most. Push N numbers in the ord ... 
- PAT 1051 Pop Sequence (25 分)
		返回 1051 Pop Sequence (25 分) Given a stack which can keep M numbers at most. Push N numbers in the ... 
- 数据结构练习 02-线性结构3. Pop Sequence (25)
		Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and p ... 
- 1051. Pop Sequence (25)
		题目如下: Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N ... 
- 【PAT】1051 Pop Sequence (25)(25 分)
		Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and p ... 
随机推荐
- Hibernate 中多对多(many-to-many)关系的查询语句
			两个对象: 学生表:Student 课程表:Course 两者的关系是多对多,当查询Student对象,并以Course对象作为条件时的sql语句写法如下: select pa from Studen ... 
- c# vue 跨域get post cookie等问题
			背景介绍: 开发微信公共号时前后端分离,后台用C#开发,前端使用vue框架,数据采用axios传输 具体问题: 1:前后端分离造成的跨域访问问题 2:跨域后cookie传输和设置问题 解决方案: 1: ... 
- JS制作一个通用的商城版历史浏览记录
			正在开发一个b2c的国外商城,昨天做了一个历史浏览记录发出来跟大家分享一下. JS: //cookie相关函数 function getCookieVal(offset) { var endst ... 
- [LintCode] 二叉树的中序遍历
			The recursive solution is trivial and I omit it here. Iterative Solution using Stack (O(n) time and ... 
- 利用epoll实现异步IO
			之前异步IO一直没搞明白,大致的理解就是在一个大的循环中,有两部分:第一部分是监听事件:第二部分是处理事件(通过添加回调函数的方式).就拿网络通信来说,可以先通过调用 select 模块中的 sele ... 
- ArcPy开发IDE
			最近时不时的使用Arcpy的脚本,这就不可避免的面临Python IDE的选择.可以用来Python开发的IDE非常的多,像Eclipse等等.尝试了一些IDE后,逐渐的固定使用下面两款. 一.Pyt ... 
- 【我的Android进阶之旅】解决 Error:CreateProcess error=216, 该版本的 %1 与您运行的 Windows 版本不兼容。请查看计算机的系统信息,了解是否需要 x86
			一.错误描述 刚刚打开Android Studio新建一个项目,然后就编译不了,报了如下所示的错误: 错误描述为: Error:CreateProcess error=216, 该版本的 %1 与您运 ... 
- Motion camera 真人动作捕捉器
			视频1 http://v.youku.com/v_show/id_XNzk4MDA2MTg4.html 视频2 http://v.youku.com/v_show/id_XNzk4MDA5OTIw.h ... 
- SQL SERVER常见等待——解决会话等待产生的系统问题
			SQL SERVER——解决会话等待产生的系统问题 转自: https://blog.csdn.net/z_cloud_for_SQL/article/details/55051215 版权声明:SQ ... 
- 关于shared pool的深入探讨(四)
			我们进一步来讨论一下shared pool的处理: 先进行相应查询,获得测试数据: [oracle@jumper udump]$ sqlplus "/ as sysdba" SQL ... 
