题解 | #nico和niconiconi#
nico和niconiconi
http://www.nowcoder.com/practice/70a03345bae6499ea4338ebc3a0b60e9
while True:
try:
n,a,b,c = map(int,input().split())
chars = input()
dp = [0]*n
for i in range(3,n):
dp[i] = dp[i-1]
if chars[i-3:i+1] == 'nico':
dp[i] = max(dp[i],dp[i-4]+a)
if i >= 5 and chars[i-5:i+1] == 'niconi':
dp[i] = max(dp[i],dp[i-6]+b)
if i >= 9 and chars[i-9:i+1] == 'niconiconi':
dp[i] = max(dp[i],dp[i-10]+c)
print(dp[-1])
except:
break