用户输出
2
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#18298 | #1110. JM的算命之术 | Accepted | 100 | 231 ms | 1912 K | C++ 11 / 869 B | JM233333 | 2019-07-15 22:34:55 |
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
class Interval {
public:
int left, right;
Interval(int l, int r) : left(l), right(r) {}
Interval() {}
friend bool operator<(const Interval& A, const Interval& B) { return (A.right < B.right); }
};
const int MAX = 2e5 + 5;
Interval intervals[MAX];
int main() {
// freopen("test.txt", "r", stdin);
int n;
while (scanf("%d", &n) != EOF) {
// 输入
for (int i = 1; i <= n; i++) {
scanf("%d %d", &intervals[i].left, &intervals[i].right);
}
// 排序
sort(intervals + 1, intervals + 1 + n);
// 求解
int res = 0;
int pos = 0;
for (int i = 1; i <= n; i++) {
if (intervals[i].left > pos) {
res++;
pos = intervals[i].right;
}
}
// 输出
printf("%d\n", res);
}
return 0;
}
35
66 80
32 38
34 35
67 68
53 94
22 74
4 51
49 73
48 91
32 65
7 98
34 44
17 84
59 97
<146 bytes omitted>
用户输出
6
系统信息
Exited with return code 0
78
24 68
23 82
79 100
49 95
55 84
17 21
2 63
23 68
6 42
57 63
18 53
9 58
65 93
70 100
<450 bytes omitted>
用户输出
10
系统信息
Exited with return code 0
854
5467 8458
7427 9416
1559 9082
3181 3196
5447 6826
1999 2772
2244 3428
4117 7212
3813 64
<9182 bytes omitted>
用户输出
49
系统信息
Exited with return code 0
240
1953 7979
5806 6542
7242 9133
8990 9000
4834 5545
8182 9685
5894 9586
3365 8189
5 6
11
<2511 bytes omitted>
用户输出
25
系统信息
Exited with return code 0
30032
218959965 690036290
166253959 736069436
361427788 677032424
118917380 279117898
623364376
<627172 bytes omitted>
用户输出
264
系统信息
Exited with return code 0
45898
765768824 839988892
891645120 934820639
897049089 915703888
819012894 912957740
30009705
<958340 bytes omitted>
用户输出
351
系统信息
Exited with return code 0
25774
6004221 6004422
2395416 2395775
222086 222631
6374948 6375202
1191857 1192036
6457035 64
<432371 bytes omitted>
用户输出
12396
系统信息
Exited with return code 0
50591
8627751 8628150
6758169 6758440
1079056 1079416
4278009 4278052
1047972 1047975
66222 66
<848740 bytes omitted>
用户输出
17853
系统信息
Exited with return code 0
100000
400381387 805067386
967986006 976613391
358312144 799345458
407097998 966818388
72874808
<2088199 bytes omitted>
用户输出
511
系统信息
Exited with return code 0
200000
81284010 81284629
9776763 9777717
63372394 63372950
66341771 66341828
61340861 61341254
<3755341 bytes omitted>
用户输出
107784
系统信息
Exited with return code 0