#include<iostream>
#include<cstring>
using namespace std;
int a[10005];
int main()
{
memset(a, 1, sizeof(a));
int l, m;
cin >> l >> m;
while (m--)
{
int start, end;
cin >> start >> end;
for (int i = start; i <= end; i++)
a[i] = 0;
}
int cnt = 0;
for (int i = 0; i <=l; i++)
{
if (a[i])
cnt++;
}
cout << cnt << endl;
return 0;
}
一道一维数组的水题,用一维数组存贮状态即可。后续只需要改变其值,最后统计一下剩余数目
http://noi.openjudge.cn/ch0106/solution/14325879/
未来还需要努力才行啊