题解 | 剩下的树

剩下的树

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

#include <iostream>
#include<cstring>
using namespace std;

const int L = 10010;
bool tree[L];
int main() {
    int l,m;
    while(cin>>l>>m){
        memset(tree,0,sizeof tree);
        while(m--){
            int left,right;
            cin>>left>>right;
            for(int i=left;i<=right;i++){
                tree[i]=true;
            }
        }
        int count=0;
        for(int i=0;i<=l;i++)
            if(tree[i]==false)count++;
        cout<<count<<endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

笑着秋招😊:我一直认为努力有回报是一件很幸福很幸福的事情,恭喜你
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务