bzoj 1510 [POI2006]Kra-The Disks——思路

题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1510

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=3e5+5,INF=1e9+5;
int n,m,h[N],r,p0;
int rdn()
{
  int ret=0;bool fx=1;char ch=getchar();
  while(ch>'9'||ch<'0'){if(ch=='-')fx=0;ch=getchar();}
  while(ch>='0'&&ch<='9') ret=(ret<<3)+(ret<<1)+ch-'0',ch=getchar();
  return fx?ret:-ret;
}
int main()
{
  n=rdn(); m=rdn(); h[0]=INF;
  for(int i=1;i<=n;i++)
    {
      h[i]=rdn(); h[i]=min(h[i],h[i-1]);
    }
  p0=n;
  for(int i=1;i<=m;i++)
    {
      r=rdn();
      while(p0&&r>h[p0])p0--;
      p0--;
    }
  printf("%d\n",p0>=0?p0+1:0);
  return 0;
}

 

posted on 2018-10-27 09:29  Narh  阅读(87)  评论(0编辑  收藏  举报

导航