题目大意 原题链接
算法分析
①通过简单的字符串处理,将名字存储到数组中
②由题,题目中的字符串比较方式与字符串的直接比较相同
③综上,可将题目化简为求字符串的最长上升子序列
Code
#include<bits/stdc++.h>
using namespace std;
int k,l,le;
string s,ans[1000005],a[1000005],c[1000005];
int main()
{
cin>>s; le=s.length(); k=0;
for(int i=0;i<le;i++)
if('A'<=s[i] && s[i]<='Z') a[++k]=s[i];
else a[k]+=s[i];
for(int i=1;i<=k;i++)
{
int x=lower_bound(c+1,c+1+l,a[i])-c;
l=max(l,x); c[x]=a[i]; ans[x]=ans[x-1]+a[i];
}
cout<<ans[l];
return 0;
}