You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
521 B
31 lines
521 B
#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;
|
|
} |