結果

問題 No.1512 作文
ユーザー Kiri8128Kiri8128
提出日時 2021-05-21 21:28:23
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 79,568 KB
最終ジャッジ日時 2023-07-31 14:26:36
合計ジャッジ時間 5,884 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,356 KB
testcase_01 AC 73 ms
71,232 KB
testcase_02 AC 73 ms
71,052 KB
testcase_03 AC 74 ms
71,456 KB
testcase_04 AC 127 ms
77,284 KB
testcase_05 AC 129 ms
77,260 KB
testcase_06 AC 129 ms
77,316 KB
testcase_07 AC 129 ms
77,248 KB
testcase_08 AC 127 ms
77,096 KB
testcase_09 AC 81 ms
76,072 KB
testcase_10 AC 80 ms
76,308 KB
testcase_11 AC 80 ms
75,920 KB
testcase_12 AC 81 ms
76,708 KB
testcase_13 AC 78 ms
75,884 KB
testcase_14 AC 109 ms
77,148 KB
testcase_15 AC 111 ms
77,208 KB
testcase_16 AC 103 ms
77,456 KB
testcase_17 AC 109 ms
77,224 KB
testcase_18 AC 115 ms
77,412 KB
testcase_19 AC 122 ms
77,468 KB
testcase_20 AC 108 ms
77,224 KB
testcase_21 AC 76 ms
75,188 KB
testcase_22 AC 77 ms
75,520 KB
testcase_23 AC 78 ms
75,524 KB
testcase_24 AC 80 ms
75,532 KB
testcase_25 AC 77 ms
75,736 KB
testcase_26 AC 72 ms
71,052 KB
testcase_27 AC 70 ms
71,428 KB
testcase_28 AC 71 ms
71,344 KB
testcase_29 AC 70 ms
71,008 KB
testcase_30 AC 73 ms
71,136 KB
testcase_31 AC 77 ms
75,916 KB
testcase_32 AC 80 ms
76,012 KB
testcase_33 AC 78 ms
75,868 KB
testcase_34 AC 79 ms
75,864 KB
testcase_35 AC 84 ms
79,568 KB
testcase_36 AC 82 ms
79,372 KB
testcase_37 AC 81 ms
77,968 KB
testcase_38 AC 80 ms
75,976 KB
testcase_39 AC 86 ms
75,856 KB
testcase_40 AC 123 ms
76,952 KB
testcase_41 AC 122 ms
76,960 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