Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
140575 沈梓珺 最长不下降子序列 C++ 通过 100 20 MS 644 KB 417 2024-03-30 15:55:41

Tests(10/10):


#include<bits/stdc++.h> using namespace std; int a[100005],f[100005],n,longest; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; if(f[longest]<=a[i]) f[++longest]=a[i]; else{ int L=0,R=longest; while(L<=R){ int mid=(L+R)>>1; if(f[mid]<=a[i]){ L=mid+1; if(f[L]>a[i]) break; } else R=mid-1; } f[L]=a[i]; } } cout<<longest<<endl; return 0; }


测评信息: