'commit'
This commit is contained in:
37
TangDou/AcWing/TiaoZhanChengXuSheJi/LZ2.2.2.cpp
Normal file
37
TangDou/AcWing/TiaoZhanChengXuSheJi/LZ2.2.2.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user