Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
119669 | 蔡胤泽 | 校门外的树 | C++ | Accepted | 1 MS | 276 KB | 572 | 2025-05-18 12:01:58 |
#include <iostream> #include <vector> using namespace std; int main() { int L, M; cin >> L >> M; vector<bool> trees(L + 1, 1); // 初始化所有树都存在 for (int i = 0; i < M; ++i) { int start, end; cin >> start >> end; for (int j = start; j <= end; ++j) { trees[j] = 0; // 标记为移除 } } int remaining = 0; for (int i = 0; i <= L; ++i) { if (trees[i]== 1) { remaining++; } } cout << remaining << endl; return 0; }