Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
52606 wzj33300 木板游戏 C++ 解答错误 5 182 MS 8060 KB 597 2022-07-19 14:01:48

Tests(1/20):


#include <bits/stdc++.h> using namespace std; struct node { int s, t; bool operator<(const node& x) const { return ((t == x.t) ? (s < x.s) : (t > x.t)); } } a[500005]; int n; int s[500005]; int f[500005]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d", &a[i].s, &a[i].t); // s[i] = a[i].s; } sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) { s[i] = a[i].s; } f[0] = 0; for (int i = 1; i <= n; i++) { f[i] = max(f[i - 1], f[upper_bound(s + 1, s + i, a[i].s) - s - 1] + 1); } printf("%d\n", f[n]); return 0; }


测评信息: