做题地址:https://www.luogu.com.cn/problem/P1047
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>using namespace std;const int N = 100010;int n, m;
bool st[N];int main() {
cin >> n >> m;for (int i = 0; i < m; i ++ ) {
int a, b; cin >> a >> b;for (int j = a; j <= b; j ++ ) st[j] = 1;}int cnt = 0;for (int i = 0; i <= n; i ++ ) if (st[i] == 0) cnt ++;cout << cnt << endl;return 0;
}