POJ 3044单调栈
2024-08-31 11:58:02
题意:
思路:
单调栈
// by SiriusRen
#include <stack>
#include <cstdio>
using namespace std;
stack<int>s;
int n,w,ans=0,xx,yy;
int main()
{
scanf("%d%d",&n,&w);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&xx,&yy);
st:if(yy&&(s.empty()||s.top()<yy))
{
s.push(yy);
ans++;
}
else if(!s.empty()&&s.top()>yy)
{
s.pop();
goto st;
}
}
printf("%d\n",ans);
}
最新文章
- .net core 学习笔记(4)-ViewComponent
- iOS开发——UI进阶篇(十四)modal
- tableView设置首尾
- 转:Ajax中的get和post两种请求方式的异同
- Centos系统使用vpnc连接cisco的vpn服务
- 修复duilib库UISlider控件的4个bug
- CodeForces 620C Pearls in a Row
- CSS3 使用选择器在页面插入内容
- viewpager循环滚动和自动轮播的问题
- Leetcode_154_Find Minimum in Rotated Sorted Array
- Python——我所学习的turtle函数库
- springboot 创建非web项目及数据源简单使用
- 【建模应用】PCA主成分分析原理详解
- Codeforces Round #432 (Div. 1, based on IndiaHacks Final Round 2017) D. Tournament Construction(dp + 构造)
- NOIP提高组—— 问题求解 与 完善程序
- Android 7.0 适配
- 关于js中的时间——计算时间差等
- 获取cookie
- list双向链表容器(常用的方法总结)
- JAVA对于程序的运行的一种解说