結果

問題 No.1512 作文
ユーザー rlangevinrlangevin
提出日時 2023-01-09 17:03:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 688 bytes
コンパイル時間 1,619 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 94,656 KB
最終ジャッジ日時 2023-08-22 19:15:35
合計ジャッジ時間 7,921 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 76 ms
71,580 KB
testcase_02 AC 75 ms
71,452 KB
testcase_03 AC 75 ms
71,304 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 104 ms
77,072 KB
testcase_10 AC 107 ms
78,132 KB
testcase_11 AC 105 ms
77,300 KB
testcase_12 AC 106 ms
78,432 KB
testcase_13 AC 106 ms
77,420 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 78 ms
75,732 KB
testcase_22 WA -
testcase_23 AC 83 ms
75,784 KB
testcase_24 AC 84 ms
75,856 KB
testcase_25 AC 83 ms
75,956 KB
testcase_26 AC 74 ms
71,192 KB
testcase_27 AC 73 ms
71,228 KB
testcase_28 AC 74 ms
71,268 KB
testcase_29 AC 74 ms
71,508 KB
testcase_30 AC 73 ms
71,080 KB
testcase_31 AC 77 ms
75,384 KB
testcase_32 AC 77 ms
75,772 KB
testcase_33 AC 76 ms
75,556 KB
testcase_34 AC 79 ms
75,668 KB
testcase_35 AC 101 ms
94,656 KB
testcase_36 AC 104 ms
94,428 KB
testcase_37 AC 91 ms
86,280 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

def alp_to_num(cha):
    num = ord(cha) - ord("a")
    return num

N = int(readline())
D = [[0] * 26 for i in range(26)]
for i in range(N):
    S = list(readline().rstrip())
    S = list(map(alp_to_num, S))
    if S != sorted(S):
        continue
    a, b = S[0], S[-1]
    if a == b:
        D[a][a] += len(S)
    else:
        D[a][b] = max(D[a][b], len(S))
        
for i in range(26):
    for j in range(i + 1, 26):
        D[i][j] += D[i][i]
        
dp = [0] * 26
for i in range(1, 26):
    dp[i] = D[0][i]
    
for i in range(1, 26):
    for j in range(i + 1, 26):
        dp[j] = max(dp[j], dp[i] + D[i][j])
        
print(max(dp))       
0