tanjingqi • 7小时前
#include <bits/stdc++.h>
using namespace std;
struct qujian {
int l, r;
};
bool cmp(qujian x, qujian y) {
if (x.l != y.l) return x.l < y.l;
return x.r < y.r;
}
qujian a[50005];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i].l >> a[i].r;
}
sort(a, a + n, cmp);
int L = a[0].l;
int R = a[0].r;
for (int i = 1; i < n; i++) {
if (a[i].l <= R + 1) {
if (a[i].r > R) {
R = a[i].r;
}
} else {
cout << "no" << endl;
return 0;
}
}
cout << L << " " << R << endl;
return 0;
}
必须AC 不AC我是傻B
评论:
请先登录,才能进行评论