Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
133754 | 黄一航 | 电视节目安排 | C++ | 解答错误 | 0 | 0 MS | 256 KB | 840 | 2024-03-02 09:04:31 |
#include <bits/stdc++.h> #define LYY_doesnt_have_m_ante long long using namespace std; pair<LYY_doesnt_have_m_ante,LYY_doesnt_have_m_ante> a[105]; bool cmp(pair<LYY_doesnt_have_m_ante,LYY_doesnt_have_m_ante> x,pair<LYY_doesnt_have_m_ante,LYY_doesnt_have_m_ante> y) { return x.second < y.second; } signed main() { LYY_doesnt_have_m_ante n; cin >> n; while (n) { for (LYY_doesnt_have_m_ante i = 1; i <= n; i++) cin >> a[i].first >> a[i].second; sort(a + 1,a + n + 1,cmp); for (LYY_doesnt_have_m_ante i = 1; i <= n; i++) cout << a[i].first << ' ' << a[i].second << '\n'; LYY_doesnt_have_m_ante nowen = a[1].second,cnt = 1; for (LYY_doesnt_have_m_ante i = 2; i <= n; i++) { if (a[i].first >= nowen) cnt++,nowen = a[i].second; } printf("%lld\n",cnt); cin >> n; } return 0; }