Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
52379 Ghost_Chris 木板游戏 C++ 解答错误 0 109 MS 4176 KB 986 2022-07-19 12:04:20

Tests(0/20):


//game #include <bits/stdc++.h> using namespace std; inline int read(){ register int x(0); register short w(1); register char c(getchar()); for (;c < '0' || c > '9';c = getchar()) if (c == '-') w = -1; for (;c >= '0' && c <= '9';c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); return x * w; } const int N(5e5 + 10); struct Node{ int l,r; }a[N]; int n,len(0),dp[N]; bool cmp(const Node &x,const Node &y){ if (x.l <= y.l) return x.r > y.r; return false; } void Init(){ n = read(); for (int i(1);i <= n;i++) a[i].l = read(),a[i].r = read(); return ; } int find(int node){ int l(1),r(len),mid; while (l <= r){ mid = l + r >> 1; if (node < dp[mid]) l = mid + 1; else r = mid - 1; } return l; } void Solve(){ sort(a + 1,a + 1 + n,cmp); for (int i(1);i <= n;i++){ int tmp(find(a[i].r)); dp[tmp] = a[i].r; len = max(len,tmp); } cout << len; return ; } int main(){ Init();Solve(); return 0; }


测评信息: