AntoineDing @ 2022-10-22 17:45:08
#include<iostream>
using namespace std;
int main()
{
int l, m, u, v, tree = 0;
cin >> l >> m;
int trees[10000] = {};
for (int i = 0; i <= l; i++)
trees[i] = 1;
for (int i = 1; i <= m; i++)
{
cin >> u >> v;
for (; u <= v; u++)
trees[u] = 0;
}
for (int i = 0; i < 10000; i++)
tree += trees[i];
cout << tree << endl;
}
by aerfahying @ 2022-10-22 18:01:17
for (int i = 0; i < 10000; i++)
tree += trees[i];
这里错了
L=10000时trees【10000】可能有但计入不了
by aerfahying @ 2022-10-22 18:03:14
@AntoineDing