You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
650 B
37 lines
650 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
const int N = 100010;
|
|
int n;
|
|
struct Node {
|
|
int st;
|
|
int ed;
|
|
const bool operator<(const Node &W) {
|
|
return ed < W.ed;
|
|
}
|
|
} w[N];
|
|
|
|
/*
|
|
5
|
|
1 2 4 6 8
|
|
3 5 7 9 10
|
|
|
|
答案:
|
|
3
|
|
*/
|
|
int main() {
|
|
cin >> n;
|
|
for (int i = 0; i < n; i++) cin >> w[i].st;
|
|
for (int i = 0; i < n; i++) cin >> w[i].ed;
|
|
sort(w, w + n);
|
|
int ans = 0, t = 0; // 设置的个数,前一个的结束时间
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
if (w[i].st > t) {
|
|
t = w[i].ed;
|
|
ans++;
|
|
}
|
|
}
|
|
cout << ans << endl;
|
|
return 0;
|
|
} |