题意:





思路:

单调栈

// 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);
}

最新文章

  1. .net core 学习笔记(4)-ViewComponent
  2. iOS开发——UI进阶篇(十四)modal
  3. tableView设置首尾
  4. 转:Ajax中的get和post两种请求方式的异同
  5. Centos系统使用vpnc连接cisco的vpn服务
  6. 修复duilib库UISlider控件的4个bug
  7. CodeForces 620C Pearls in a Row
  8. CSS3 使用选择器在页面插入内容
  9. viewpager循环滚动和自动轮播的问题
  10. Leetcode_154_Find Minimum in Rotated Sorted Array
  11. Python——我所学习的turtle函数库
  12. springboot 创建非web项目及数据源简单使用
  13. 【建模应用】PCA主成分分析原理详解
  14. Codeforces Round #432 (Div. 1, based on IndiaHacks Final Round 2017) D. Tournament Construction(dp + 构造)
  15. NOIP提高组—— 问题求解 与 完善程序
  16. Android 7.0 适配
  17. 关于js中的时间——计算时间差等
  18. 获取cookie
  19. list双向链表容器(常用的方法总结)
  20. JAVA对于程序的运行的一种解说

热门文章

  1. 【HDU 5015】233 Matrix
  2. 什么是EL表达式
  3. 10.QT程序框架与connect
  4. 9. Palindrome Number[E]回文数
  5. python中set集合的使用
  6. PHP邮件发送库:Swiftmailer
  7. 构建工具系列一--Travis-cli
  8. POJ 1328 Radar Installation 【贪心 区间选点】
  9. ajax第二天学习
  10. Django Views Decorator