datobimake @ 2024-07-04 17:44:41
#include<iostream>
using namespace std;
int main()
{
int l,m,s,e,a[1001],cnt=0;
cin >> l >> m;
for(int i = 0;i <= l;i++)
a[i] = 1;
for(int i = 1;i <= m;i++)
{
cin >> s >> e;
for(int j = s;j <= e;j++)
a[j] = 0;
}
for(int i = 0;i <= l;i++)
{
if(a[i] == 1)
cnt++;
}
cout << cnt;
return 0;
}
by zhouzihang1 @ 2024-07-04 17:48:30
@datobimake
by _Liyx_ @ 2024-07-04 17:57:48
@datobimake 第5行,是a[10005]
by datobimake @ 2024-07-04 21:52:44
@zhouzihang1 谢谢
by datobimake @ 2024-07-04 21:53:11
@Liyx 谢谢