题目:书P40-41

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

const int MAX_LEN = 100005;
int n;

int s[MAX_LEN], t[MAX_LEN];

struct Work {
int Start;
int End;
}_work[MAX_LEN];

bool Cmp(const Work& w1, const Work& w2) {
return w1.End < w2.End;
}

int main() {
int Result = 0; int tmp = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &_work[i].Start);
}
for (int i = 0; i < n; i++) {
scanf("%d", &_work[i].End);
}
sort(_work, _work + n, Cmp);
for (int i = 0; i < n; i++) {
if (tmp <= _work[i].Start) {
tmp = _work[i].End;
Result++;
}
}
printf("%d", Result);
system("pause");
return 0;
}