Run ID:115154

提交时间:2025-03-29 15:31:21

#include<iostream> using namespace std; int a[10001]; int main(){ int l,m,s,e,sum=0; cin>>l>>m; //从0—l种上树。 for(int k=0;k<=l;k++){ a[k]=1; } for(int i=1;i<=m;i++){//砍树次数。 cin>>s>>e; for(int j=s;j<=e;j++){ if(a[j]==1){//表示j位置有棵树。 a[j]=0;//砍树标记。 sum++;//记录砍树的数量。 } } } cout<<l+1-sum; return 0; }