题解 | 剩下的树

剩下的树

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")

全部评论

相关推荐

码农索隆:传音老登来也。 但是这个我不知道怎么回答,不仅仅传音吧,很多公司在候选人不第一时间接受offer或主动将报道时间延期时,都会再从池子里面捞人,直到l捞到满足公司所有要求的人。
秋招的第一个offer,...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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