Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
133841 | 吴晨曦 | 电视节目安排 | C++ | 通过 | 100 | 3 MS | 256 KB | 534 | 2024-03-02 09:49:06 |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 005; struct Node{ int s, e; bool operator < (const Node &o) const { if (e != o.e) return e < o.e; return s < o.s; } }; int main() { int n; while (cin >> n) { if (!n) break; static Node a[N]; for (int i = 1; i <= n; i++) cin >> a[i].s >> a[i].e; sort (a + 1, a + n + 1); int nowe = a[1].e, s = 0; for (int i = 2; i <= n; i++) { if (nowe <= a[i].s) nowe = a[i].e, s++; } cout << s + 1 << endl; } }