Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
52617 wzj33300 木板游戏 C++ 通过 100 153 MS 6116 KB 666 2022-07-19 14:44:23

Tests(20/20):


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


测评信息: