首页 > 其他 > 详细

51nod 1289 大鱼吃小鱼

时间:2017-09-14 19:52:59      阅读:270      评论:0      收藏:0      [点我收藏+]
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int a[maxn],b[maxn];
stack<int>s;
int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i];
    int ans =0;
    for(int i=1;i<=n;i++)
    {
        ans++;
        if(b[i] )
            s.push(a[i]);
        else {
            while(!s.empty() && a[i] > s.top() )
            {
                ans--;
                s.pop();
            }
            if(!s.empty() && a[i] < s.top())
            {
                ans--;
            }
        }
    }
    cout<< ans<<endl;
}

 



51nod 1289 大鱼吃小鱼

原文:http://www.cnblogs.com/Draymonder/p/7522113.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!