编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#28299 | #1008. H. 开疆辟土,公司成立 | Compile Error | 0 | 0 ms | 0 K | C++ 17 / 904 B | 人试92-何雨萌 | 2020-06-30 21:57:30 |
#include <bits/stdc++.h>
using namespace std;
struct Interval {
int left;
int right;
operator<(const Interval &x) { //用于sort
return (right < x.right || (right == x.right && left > x.left));
}
} tot[1000000];
//尽可能往右选的同时保证每个区间都有个点
int choose_point(Interval *x, int n) {
sort(x, x + n);
int ans = 1, r = x[0].right;
for (int i = 1; i < n; i++) {
if (x[i].left > r) {
r = x[i].right;
ans++;
}
}
return ans;
}
int main() {
int n;
cin >> n;
if (n < 1 || n > 1000000)
return 0;
for (int i = 0; i < n; i++) {
cin >> tot[i].left;
cin >> tot[i].right;
if (tot[i].left < 1 || tot[i].left > 1000000 || tot[i].right < 1 || tot[i].right > 1000000)
return 0;
}
cout << choose_point(tot, n);
return 0;
}
编译信息
/sandbox/1/a.cpp:7:34: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive]
operator < (const Interval &x) { //用于sort
^