记录编号 |
601428 |
评测结果 |
WWWWWWWWWWWWWWWWWWWW |
题目名称 |
3114.二分图 |
最终得分 |
0 |
用户昵称 |
wdsjl |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
1.127 s |
提交时间 |
2025-06-19 17:05:13 |
内存使用 |
6.32 MiB |
显示代码纯文本
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
struct N {
int l, r;
bool operator<(const N& o) const {
return r < o.r || (r == o.r && l < o.l);
}
};
int n;
int main() {
freopen("erfentu.in","r",stdin);
freopen("erfentu.out","w",stdout);
scanf("%d", &n);
vector<N> a(n);
for (int i = 0; i < n; ++i) {
scanf("%d%d", &a[i].l, &a[i].r);
}
sort(a.begin(), a.end());
set<int> m, av;
for (int i = 1; i <= n; ++i) av.insert(i);
int c = 0;
for (vector<N>::const_iterator it = a.begin(); it != a.end(); ++it) {
int l = it->l, r = it->r;
set<int>::iterator it_av = av.lower_bound(l);
if (it_av != av.end() && *it_av <= r) {
c++;
m.insert(*it_av);
av.erase(it_av);
}
}
printf("%d\n", c);
return 0;
}