【NOIP2005】【Luogu1047】校门外的树

problem

solution

codes

#include<iostream>
using namespace std;
int a[100010], ans;
int main(){
    int l, m;  cin>>l>>m;
    for(int i = 0; i <= l; i++)a[i] = 1;
    for(int i = 0; i < m; i++){
        int x, y;  cin>>x>>y;
        for(int j = x; j <= y; j++)a[j] = 0;
    }
    for(int i = 0; i <= l; i++)if(a[i])ans++;
    cout<<ans;
    return 0;
}
原文地址:https://www.cnblogs.com/gwj1314/p/9444686.html