#11234: C++


za455096 (455096)

學校 : 臺北市私立延平高級中學
編號 : 57236
來源 : [203.72.178.252]
最後登入時間 :
2018-03-28 11:02:28
b139. NOIP2005 2.校门外的树 -- NOIP2005普及組 | From: [203.72.178.252] | 發表日期 : 2016-08-03 13:53

#include <iostream>
using namespace std;
int main()
{
int L,M;
while(cin>>L>>M)
{
int plant[L+1];
for(int i=0; i<=L; i++) plant[i]=1;
int ans=L+1;
while(M--)
{
int s,e;
cin>>s>>e;
for(int j=s; j<=e; j++)
{
if(plant[j]==1) ans--;
plant[j]=0;
}
}
cout << ans <<'\n';
}
return 0;
}

 
ZeroJudge Forum