yyyyqqxxxx09 @ 2024-02-07 21:04:48
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int l,m,s=0,vis[1000+10];
int main(){
memset(vis,0,sizeof(vis));
cin>>l>>m;
for(int i=0;i<=l;i++)
vis[i]=0;
for(int i=0;i<m;i++){
int head,tail;
cin>>head>>tail;
for(int j=head;j<=tail;j++){
if(vis[j]==0)
vis[j]=1;
}
}
for(int i=0;i<=l;i++){
if(vis[i]==0)
s++;
}
cout<<s<<endl;
return 0;
}
by yyyyqqxxxx09 @ 2024-02-07 21:05:38
只有第一组数据对了,后面全部显示Runtime error,不知道为啥
by xiaoshumiao @ 2024-02-07 21:06:52
@yyyyqqxxxx09 数组开小了
by yyyyqqxxxx09 @ 2024-02-07 21:09:55
@xiaoshumiao ok了,感谢感谢