本人马上绿名
求助--->P1020
本人100分代码(满分两百)
记录详情
代码
#include <bits/stdc++.h>
using namespace std;
const int N=5e4+10;
int n;
int h[N],f[N],q[N];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string line;
getline(cin,line);
stringstream sin(line);
while(sin>>h[n]) n++;
int res=0,cnt=0;
for(int i=0;i<n;i++){
f[i]=1;
for(int j=0;j<i;j++)
if(h[i]<=h[j])
f[i]=max(f[i],f[j]+1);
res=max(res,f[i]);
int k=0;
while(k<cnt && q[k]<h[i]) k++;
if(k==cnt) q[cnt++]=h[i];
else q[k]=h[i];
}
cout<<res<<endl;
cout<<cnt<<endl;
return 0;
}
感谢!!!
欢迎互关