提交时间:2023-11-25 09:37:10

运行 ID: 111986

#include <bits/stdc++.h> using namespace std; int n,x[100001],Lis[100001],i=0,longest=0; int main() { char str; while(scanf("%d",&x[i])) { if(!i) Lis[longest++]=x[i]; else { if(x[i]<Lis[longest-1]) { int j=upper_bound(Lis,Lis+longest,x[i])-Lis; Lis[j]=x[i]; } else { Lis[longest++]=x[i]; } } i++; str = cin.get(); if(str == '\n') break; } printf("max=%d\n",longest); for(int i=0;i<longest;i++) cout<<Lis[i]<<" "; return 0; }