Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
140560 | 陈志轩 | 最长不下降子序列 | C++ | 通过 | 100 | 23 MS | 2708 KB | 407 | 2024-03-30 15:53:19 |
#include<bits/stdc++.h> using namespace std; long long dp[114514],q[114514],a[114514],maxn; int main(){ memset(q,0x3f3f3f3f,sizeof(q)); int n; cin>>n; for (int i = 1;i <= n;i++){ cin>>a[i]; } for (int i = 1;i <= n;i++){ dp[i] = upper_bound(q + 1,q + n + 1,a[i]) - q; q[dp[i]] = a[i]; } for (int i = 1;i <= n;i++){ maxn = max(maxn,dp[i]); } cout<<maxn<<endl; return 0; }