結果

問題 No.1512 作文
ユーザー tcltktcltk
提出日時 2021-06-25 16:42:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 681 ms / 2,000 ms
コード長 820 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 132,576 KB
最終ジャッジ日時 2023-09-07 13:37:30
合計ジャッジ時間 13,701 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 209 ms
80,912 KB
testcase_01 AC 207 ms
80,932 KB
testcase_02 AC 213 ms
80,756 KB
testcase_03 AC 208 ms
80,916 KB
testcase_04 AC 543 ms
113,312 KB
testcase_05 AC 541 ms
113,052 KB
testcase_06 AC 539 ms
113,604 KB
testcase_07 AC 538 ms
113,132 KB
testcase_08 AC 539 ms
113,892 KB
testcase_09 AC 205 ms
80,932 KB
testcase_10 AC 206 ms
81,020 KB
testcase_11 AC 208 ms
80,932 KB
testcase_12 AC 212 ms
80,780 KB
testcase_13 AC 205 ms
80,932 KB
testcase_14 AC 260 ms
85,800 KB
testcase_15 AC 257 ms
86,088 KB
testcase_16 AC 256 ms
85,936 KB
testcase_17 AC 253 ms
85,748 KB
testcase_18 AC 254 ms
85,912 KB
testcase_19 AC 254 ms
85,812 KB
testcase_20 AC 252 ms
85,676 KB
testcase_21 AC 213 ms
80,728 KB
testcase_22 AC 210 ms
80,732 KB
testcase_23 AC 209 ms
80,916 KB
testcase_24 AC 205 ms
80,704 KB
testcase_25 AC 206 ms
80,700 KB
testcase_26 AC 207 ms
80,908 KB
testcase_27 AC 205 ms
80,936 KB
testcase_28 AC 203 ms
80,912 KB
testcase_29 AC 202 ms
80,736 KB
testcase_30 AC 206 ms
80,684 KB
testcase_31 AC 207 ms
81,592 KB
testcase_32 AC 205 ms
81,612 KB
testcase_33 AC 205 ms
81,504 KB
testcase_34 AC 218 ms
83,988 KB
testcase_35 AC 216 ms
83,812 KB
testcase_36 AC 215 ms
83,736 KB
testcase_37 AC 211 ms
83,572 KB
testcase_38 AC 226 ms
83,928 KB
testcase_39 AC 223 ms
84,036 KB
testcase_40 AC 681 ms
127,228 KB
testcase_41 AC 426 ms
132,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """4
# abc
# ab
# bbccdd
# de
# """
# sys.stdin = io.StringIO(_INPUT)


N = int(input())
S = [input() for _ in range(N)]
L = []
for s in S:
    ok = True
    for i in range(len(s)-1):
        if s[i] > s[i+1]:
            ok = False
            break
    if ok:
        L.append((ord(s[0])-ord('a'), ord(s[-1])-ord('a'), len(s)))
L.sort(key=lambda x: (x[0], x[1], -x[2]))

dp = [0] * 26
for k1, k2, l in L:

    for k in reversed(range(26)):
        dp[k] = max(dp[k], dp[k])
        if k <= k1:
            dp[k2] = max(dp[k2], dp[k]+l)

ans = max(dp)
print(ans)
0