結果

問題 No.1512 作文
ユーザー convexineqconvexineq
提出日時 2021-05-21 21:29:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 453 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 101,568 KB
最終ジャッジ日時 2024-04-18 14:32:29
合計ジャッジ時間 3,851 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,916 KB
testcase_01 AC 36 ms
52,772 KB
testcase_02 AC 34 ms
53,012 KB
testcase_03 AC 36 ms
53,248 KB
testcase_04 AC 95 ms
93,524 KB
testcase_05 AC 96 ms
92,776 KB
testcase_06 AC 92 ms
93,428 KB
testcase_07 AC 92 ms
93,440 KB
testcase_08 AC 91 ms
93,104 KB
testcase_09 AC 69 ms
64,512 KB
testcase_10 AC 76 ms
65,456 KB
testcase_11 AC 70 ms
64,948 KB
testcase_12 AC 74 ms
65,532 KB
testcase_13 AC 72 ms
64,908 KB
testcase_14 AC 69 ms
77,736 KB
testcase_15 AC 71 ms
78,020 KB
testcase_16 AC 69 ms
77,628 KB
testcase_17 AC 72 ms
77,748 KB
testcase_18 AC 68 ms
77,976 KB
testcase_19 AC 69 ms
77,992 KB
testcase_20 AC 69 ms
77,732 KB
testcase_21 AC 38 ms
54,148 KB
testcase_22 AC 37 ms
52,632 KB
testcase_23 AC 39 ms
53,764 KB
testcase_24 AC 42 ms
55,264 KB
testcase_25 AC 40 ms
53,792 KB
testcase_26 AC 36 ms
53,152 KB
testcase_27 AC 35 ms
53,180 KB
testcase_28 AC 37 ms
53,284 KB
testcase_29 AC 36 ms
53,836 KB
testcase_30 AC 37 ms
53,800 KB
testcase_31 AC 36 ms
52,628 KB
testcase_32 AC 37 ms
53,672 KB
testcase_33 AC 37 ms
52,104 KB
testcase_34 AC 37 ms
54,316 KB
testcase_35 AC 46 ms
62,396 KB
testcase_36 AC 45 ms
63,580 KB
testcase_37 AC 42 ms
58,624 KB
testcase_38 AC 42 ms
64,244 KB
testcase_39 AC 43 ms
62,832 KB
testcase_40 AC 95 ms
101,568 KB
testcase_41 AC 93 ms
101,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,*S = open(0).read().split()
n = int(n)

g = [[-1]*26 for _ in range(26)]
for i in range(26): g[i][i] = 0
dp = [0]*26
for s in S:
    if "".join(sorted(s)) != s:
        continue
    a = ord(s[0])-97
    b = ord(s[-1])-97
    if a != b:
        g[a][b] = max(g[a][b],len(s))
    else:
        g[a][a] += len(s)

ans = 0
for i in range(26):
    dp[i] += g[i][i]
    for j in range(i+1,26):
        dp[j] = max(dp[j],dp[i]+ max(0,g[i][j]))
print(max(dp))
0