松散子序列Python

题目:

 

import os
import sys
import math
import re
from bisect import *
from heapq import *
input =lambda:sys.stdin.readline().rstrip('\r\n')
def I():
  return input()
def II():
  return int(input())
def LII():
  return list(map(int,input.split()))
# 请在此输入您的代码
def solve():
    s = I()
    n = len(s)
    f = [[0 for j in range(2)]for i in range(n+1)]
    f[0][0] = 0
    f[0][1] = ord(s[0])-ord('a')+1
    for i in range(1,n):
        f[i][0]=max(f[i-1][1],f[i-1][0])
        f[i][1]=max(f[i-2][1],f[i-2][0])+ord(s[i])-ord('a')+1
    print(max(f[n-1][1],f[n-1][0]))
for _ in range(1):solve()

  

posted @ 2024-02-29 21:45  你也喜欢阿狸吗  阅读(59)  评论(0)    收藏  举报