結果

問題 No.1512 作文
ユーザー Kiri8128Kiri8128
提出日時 2021-05-21 21:28:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 76,324 KB
最終ジャッジ日時 2024-04-18 14:30:35
合計ジャッジ時間 3,658 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,236 KB
testcase_01 AC 35 ms
53,964 KB
testcase_02 AC 35 ms
53,344 KB
testcase_03 AC 34 ms
53,940 KB
testcase_04 AC 92 ms
75,788 KB
testcase_05 AC 91 ms
75,536 KB
testcase_06 AC 86 ms
76,124 KB
testcase_07 AC 86 ms
76,064 KB
testcase_08 AC 89 ms
75,696 KB
testcase_09 AC 45 ms
68,600 KB
testcase_10 AC 46 ms
69,940 KB
testcase_11 AC 46 ms
68,660 KB
testcase_12 AC 45 ms
70,076 KB
testcase_13 AC 48 ms
68,612 KB
testcase_14 AC 77 ms
75,656 KB
testcase_15 AC 76 ms
76,212 KB
testcase_16 AC 68 ms
76,148 KB
testcase_17 AC 75 ms
75,684 KB
testcase_18 AC 78 ms
76,036 KB
testcase_19 AC 85 ms
76,324 KB
testcase_20 AC 73 ms
76,248 KB
testcase_21 AC 38 ms
60,276 KB
testcase_22 AC 40 ms
59,772 KB
testcase_23 AC 41 ms
59,468 KB
testcase_24 AC 43 ms
61,116 KB
testcase_25 AC 42 ms
60,712 KB
testcase_26 AC 37 ms
52,860 KB
testcase_27 AC 35 ms
53,020 KB
testcase_28 AC 35 ms
53,344 KB
testcase_29 AC 35 ms
51,812 KB
testcase_30 AC 36 ms
52,992 KB
testcase_31 AC 39 ms
59,740 KB
testcase_32 AC 42 ms
60,908 KB
testcase_33 AC 41 ms
58,900 KB
testcase_34 AC 41 ms
60,144 KB
testcase_35 AC 47 ms
68,912 KB
testcase_36 AC 46 ms
69,136 KB
testcase_37 AC 44 ms
66,388 KB
testcase_38 AC 46 ms
70,068 KB
testcase_39 AC 49 ms
73,140 KB
testcase_40 AC 91 ms
75,384 KB
testcase_41 AC 92 ms
75,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
X = [0] * 26
Y = [[0] * 26 for _ in range(26)]
for _ in range(N):
    S = [ord(a) - 97 for a in input()]
    for a, b in zip(S, S[1:]):
        if a > b:
            break
    else:
        l = S[0]
        r = S[-1]
        m = len(S)
        if l == r:
            X[l] += m
        else:
            Y[l][r] = max(Y[l][r], m)

Z = [0] * 27
for i in range(26):
    Z[i] += X[i]
    for j in range(i + 1, 26):
        Z[j] = max(Z[j], Z[i] + Y[i][j])
print(max(Z))
0