slry666 @ 2022-08-18 10:15:41
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,x[10050],y[10050],ans,s[10050];
int main(){
cin>>n>>m;
for(i=1;i<=n+1;i++){
s[i]=0;
}
for(i=1;i<=m;i++){
cin>>x[i]>>y[i];
for(j=x[i];j<=y[i];j++){
s[j]=1;
}
}
for(i=1;i<=n+1;i++){
if(s[i]==0) ans++;
}
cout<<ans;
}
by slry666 @ 2022-08-18 10:16:09
第一个测试点废
by How1ver @ 2022-08-18 10:38:09
@slry666 应该从点0开始吧
by xiaoPanda @ 2022-08-18 10:38:52
从点0开始,到点n
by xiaoPanda @ 2022-08-18 10:39:28
for(i=1;i<=n+1;i++){
if(s[i]==0) ans++;
}
改成
for(i=0;i<=n;i++){
if(s[i]==0) ans++;
}
by slry666 @ 2022-08-18 10:42:51
谢谢
by sijiajun @ 2022-08-18 10:44:53
关于我愣了一会儿就多了一条回复这件事。
by sijiajun @ 2022-08-18 10:45:38
或者说是四条
by lizixuan1018 @ 2022-08-18 11:10:03
同意上层