Files
python/LuoGu/RuMen/P1047.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

31 lines
551 B
C++

#include <bits/stdc++.h>
using namespace std;
//P1047 校门外的树
int main() {
int L, M;
cin >> L >> M;
int array[L];
for (int i = 0; i <= L; i++) {
array[i] = 0;
}
for (int i = 1; i <= M; i++) {
int s, t;
cin >> s >> t;
for (int j = s; j <= t; j++) {
array[j] = 1;
}
}
int count = 0;
for (int i = 0; i <= L; i++) {
if (array[i] == 0) {
count++;
}
}
cout << count << endl;
return 0;
}