#include<bits/stdc++.h>
using namespace std;
const int M=1e6+5;
int a[M],dp[M];
int maxx;
int main()
{
string b;
cin>>b;
dp[1]=b[0]-'a'+1,dp[2]=b[1]-'a'+1;
maxx=max(dp[1],dp[2]);
for(int i=3;i<=b.size();i++)
{
int t=b[i-1]-'a'+1;
dp[i]=max(dp[i-2],dp[i-3])+t;
maxx=max(maxx,dp[i]);
}
cout<<maxx;
}
蓝桥杯 松散子序列 动态规划题解
最新推荐文章于 2024-08-02 11:53:45 发布