题解 | 剩下的树

剩下的树

https://www.nowcoder.com/practice/f5787c69f5cf41499ba4706bc93700a2

#include <stdio.h>
#include <vector>
using namespace std;
int main(){
    vector<int> tree;
    int l,m;
    int low,high;
    scanf("%d%d",&l,&m);
    for(int i=0;i<=l;++i){
        tree.push_back(1);
    }
    for(int j=0;j<m;++j){
        scanf("%d%d",&low,&high);
        for(int i=low;i<=high;++i){
            tree[i]=0;
        }
    }
    int count=0;
    for(int i=0;i<=l;++i){
        if(tree[i]==1){++count;}
    }
    printf("%d",count);
    return 0;
}

#shit#
全部评论

相关推荐

04-03 22:39
重庆大学 Java
点赞 评论 收藏
分享
05-14 20:34
门头沟学院 Java
窝补药贝八股:管他们,乱说,反正又不去,直接说680
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务