【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;
}
posted @ 2018-06-07 15:25  gwj1139177410  阅读(97)  评论(0编辑  收藏  举报
选择