結果

問題 No.1512 作文
ユーザー strangerxxxstrangerxxx
提出日時 2021-05-21 22:16:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 549 bytes
コンパイル時間 117 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 15,720 KB
最終ジャッジ日時 2024-04-18 15:45:41
合計ジャッジ時間 9,828 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 33 ms
10,752 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 30 ms
10,624 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 58 ms
11,264 KB
testcase_10 AC 60 ms
11,236 KB
testcase_11 AC 59 ms
11,180 KB
testcase_12 AC 63 ms
11,240 KB
testcase_13 AC 63 ms
11,236 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 32 ms
10,624 KB
testcase_22 AC 31 ms
10,752 KB
testcase_23 AC 32 ms
10,752 KB
testcase_24 AC 32 ms
10,624 KB
testcase_25 WA -
testcase_26 AC 30 ms
10,624 KB
testcase_27 AC 31 ms
10,752 KB
testcase_28 AC 29 ms
10,624 KB
testcase_29 AC 29 ms
10,752 KB
testcase_30 AC 29 ms
10,752 KB
testcase_31 AC 31 ms
10,752 KB
testcase_32 AC 29 ms
10,880 KB
testcase_33 AC 30 ms
10,624 KB
testcase_34 AC 32 ms
10,752 KB
testcase_35 AC 38 ms
15,592 KB
testcase_36 AC 39 ms
15,720 KB
testcase_37 AC 35 ms
13,824 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 893 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def resolve():
    n = int(input())
    chars = ord("z") - ord("a") + 1
    dp = [0] * (chars)
    next_dp = dp[:]
    for _ in range(n):
        s = input()
        lens = len(s)
        if list(s) != sorted(list(s)):
            continue
        head = ord(s[0]) - ord("a")
        tail = ord(s[-1]) - ord("a")
        for i in range(tail):
            next_dp[i] = dp[i]
        for i in range(tail, chars):
            next_dp[i] = max(dp[i], dp[head] + lens)
        dp = next_dp[:]
    print(dp[-1])


if __name__ == '__main__':
    resolve()
0