/* I will wait for you */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<vector>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<string>
#define make make_pair
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
const int maxn=1000010;
const int maxm=1010;
const int maxs=26;
const int INF=1<<29;
const int P=1000000007;
const double error=1e-9;
int q[maxn];
int main()
{
int n,ans=0,top=0;scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int u,v;scanf("%d%d",&u,&v);
while(top&&q[top]>v) top--;
if(!top||q[top]<v) ans++,q[++top]=v;
}
printf("%d\n",ans);
return 0;
}
BZOJ1113【单调栈】
最新推荐文章于 2018-10-26 19:50:05 发布