提交时间:2024-03-30 15:53:19
运行 ID: 140560
#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; }