1 条题解
-
0
#include <bits/stdc++.h> using u32 = unsigned; using i64 = long long; using u64 = unsigned long long; using u128 = unsigned __int128; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; std::vector<std::array<int, 2>> a(n + 1); for (int i = 1; i <= n; i ++) { std::cin >> a[i][0] >> a[i][1]; } std::sort(a.begin() + 1, a.end()); int r = a[1][1]; int l = a[1][0]; for (int i = 2; i <= n; i++) { auto [L, R] = a[i]; if (L <= r) { r = std::max(r, R); continue; } std::cout << l << " " << r << "\n"; l = L; r = R; } std::cout << l << " " << r << "\n"; return 0; }
- 1
信息
- ID
- 191
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- (无)
- 递交数
- 30
- 已通过
- 18
- 上传者