結果

問題 No.1512 作文
ユーザー U SU S
提出日時 2021-05-21 22:00:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 436 ms / 2,000 ms
コード長 907 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 82,532 KB
実行使用メモリ 144,364 KB
最終ジャッジ日時 2024-04-18 15:27:49
合計ジャッジ時間 6,260 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
61,124 KB
testcase_01 AC 51 ms
61,140 KB
testcase_02 AC 49 ms
61,940 KB
testcase_03 AC 49 ms
61,336 KB
testcase_04 AC 295 ms
111,056 KB
testcase_05 AC 297 ms
111,052 KB
testcase_06 AC 292 ms
110,932 KB
testcase_07 AC 287 ms
111,048 KB
testcase_08 AC 296 ms
110,936 KB
testcase_09 AC 50 ms
63,116 KB
testcase_10 AC 49 ms
63,068 KB
testcase_11 AC 51 ms
62,144 KB
testcase_12 AC 50 ms
63,564 KB
testcase_13 AC 51 ms
62,512 KB
testcase_14 AC 115 ms
77,492 KB
testcase_15 AC 135 ms
78,004 KB
testcase_16 AC 116 ms
78,148 KB
testcase_17 AC 112 ms
77,564 KB
testcase_18 AC 114 ms
77,444 KB
testcase_19 AC 114 ms
77,332 KB
testcase_20 AC 112 ms
77,548 KB
testcase_21 AC 51 ms
63,232 KB
testcase_22 AC 49 ms
60,796 KB
testcase_23 AC 50 ms
62,120 KB
testcase_24 AC 51 ms
62,448 KB
testcase_25 AC 51 ms
62,244 KB
testcase_26 AC 49 ms
60,524 KB
testcase_27 AC 48 ms
61,560 KB
testcase_28 AC 48 ms
61,384 KB
testcase_29 AC 49 ms
61,656 KB
testcase_30 AC 48 ms
61,560 KB
testcase_31 AC 52 ms
63,596 KB
testcase_32 AC 53 ms
63,284 KB
testcase_33 AC 52 ms
63,116 KB
testcase_34 AC 63 ms
68,140 KB
testcase_35 AC 54 ms
63,284 KB
testcase_36 AC 53 ms
63,420 KB
testcase_37 AC 52 ms
64,032 KB
testcase_38 AC 59 ms
67,272 KB
testcase_39 AC 63 ms
69,464 KB
testcase_40 AC 436 ms
144,364 KB
testcase_41 AC 329 ms
137,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import sys
# input = sys.stdin.readline
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
import math
import bisect
from copy import deepcopy as dc
from itertools import accumulate
from collections import Counter, defaultdict, deque
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1
inf = int(1e30)
mod = 998244353

n = int(input())
s = []
for i in range(n):
    si = input()
    for j in range(len(si)-1):
        if ord(si[j]) > ord(si[j+1]):
            break
    else:s.append(si)
s.sort()
dp = [[0]*26 for i in range(len(s)+1)]
for i in range(1,len(s)+1):
    tar = s[i-1]
    front = tar[0]
    bottom = tar[-1]
    for j in range(ord(front)-ord("a")+1):
        dp[i][ord(bottom)-ord("a")] = max(dp[i-1][j]+len(tar), dp[i][ord(bottom)-ord("a")])
    for j in range(26):
        dp[i][j] = max(dp[i - 1][j], dp[i][j])
print(max(dp[len(s)]))

0