poj 2808 校园外的树

#include<iostream>

using namespace std;

int main()

{

int L,i,j,n;

bool trees[10001];

for(i=0;i<10001;i++)

trees[i]=true;

cin>>L>>n;

for(i=0;i<n;i++){

int begin,end;

cin>>begin>>end;

for(j=begin;j<=end;j++)

trees[j]=false;

}

int count=0;

for(i=0;i<=L;i++)

if(trees[i]) count++;

cout<<count<<endl;

return 0;

}

 

posted @ 2012-04-09 20:14  逝者*恋世  阅读(169)  评论(0编辑  收藏  举报