T2

论坛 期权论坛 脚本     
匿名技术用户   2020-12-27 09:47   70   0
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
void read(int& x)
{
 x = 0;char c = getchar();
 while(c<'0'||c>'9')c=getchar();
 while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
}
#define MAXN 1000010
#define forx(i,s,t) for(int i = (s);i <= (t);i++)
int low[MAXN],high[MAXN];
int bestans,nowans,last;
void swap(int& x,int& y)
{
 int t = x;
 x = y;
 y = t;
}
int main(void)
{
#define MYAK
#ifdef MYAK
 freopen("sequence.in","r",stdin);
 freopen("sequence.out","w",stdout);
#endif
 read(n);
 forx(i,1,n)read(low[i]),read(high[i]);
 bestans = nowans = 1;
 last = low[1];
 forx(i,2,n)
 {
  if(high[i]<last)
  {
   bestans = max(bestans,nowans);
   nowans = 1;
   last = low[i];
  }
  else
  {
   ++nowans;
   if(low[i]<=last)continue;
   else last = low[i];
  }
 }
 bestans = max(bestans,nowans);
 forx(i,1,n/2)swap(low[i],low[n-i+1]),swap(high[i],high[n-i+1]);
 nowans = 1;
 last = high[1];
 forx(i,2,n)
 {
  if(low[i]>last)
  {
   bestans = max(bestans,nowans);
   nowans = 1;
   last = high[i];
  }
  else
  {
   ++nowans;
   if(high[i]>=last)continue;
   else last = high[i];
  }
 }
 bestans = max(bestans,nowans);
 printf("%d\n",bestans);
 return 0;
}

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP