結果

問題 No.1512 作文
ユーザー tobusakanatobusakana
提出日時 2022-11-26 11:21:35
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 86,592 KB
実行使用メモリ 87,628 KB
最終ジャッジ日時 2023-07-25 21:33:54
合計ジャッジ時間 7,622 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,136 KB
testcase_01 AC 76 ms
71,308 KB
testcase_02 AC 74 ms
71,144 KB
testcase_03 AC 77 ms
70,936 KB
testcase_04 AC 276 ms
84,260 KB
testcase_05 AC 261 ms
84,788 KB
testcase_06 AC 260 ms
84,340 KB
testcase_07 AC 259 ms
84,360 KB
testcase_08 AC 253 ms
84,132 KB
testcase_09 AC 76 ms
71,256 KB
testcase_10 AC 77 ms
71,124 KB
testcase_11 AC 77 ms
71,200 KB
testcase_12 AC 77 ms
71,056 KB
testcase_13 AC 74 ms
71,316 KB
testcase_14 AC 141 ms
78,404 KB
testcase_15 AC 135 ms
78,312 KB
testcase_16 AC 132 ms
78,400 KB
testcase_17 AC 131 ms
78,352 KB
testcase_18 AC 132 ms
78,064 KB
testcase_19 AC 132 ms
78,076 KB
testcase_20 AC 136 ms
78,404 KB
testcase_21 AC 76 ms
71,312 KB
testcase_22 AC 77 ms
71,192 KB
testcase_23 AC 77 ms
71,116 KB
testcase_24 AC 79 ms
71,268 KB
testcase_25 AC 77 ms
70,796 KB
testcase_26 AC 76 ms
70,824 KB
testcase_27 AC 75 ms
71,024 KB
testcase_28 AC 75 ms
70,824 KB
testcase_29 AC 76 ms
71,020 KB
testcase_30 AC 75 ms
71,264 KB
testcase_31 AC 80 ms
75,628 KB
testcase_32 AC 79 ms
75,668 KB
testcase_33 AC 78 ms
75,664 KB
testcase_34 AC 85 ms
75,820 KB
testcase_35 AC 84 ms
76,108 KB
testcase_36 AC 85 ms
75,936 KB
testcase_37 AC 81 ms
75,396 KB
testcase_38 AC 86 ms
76,444 KB
testcase_39 AC 88 ms
76,524 KB
testcase_40 AC 275 ms
87,628 KB
testcase_41 AC 209 ms
86,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = [input() for i in range(N)]

# dp[X] = アルファベットXまで進んだときの最大得点
# あらかじめソートしておく

S = sorted(S)
dp = [0] * 26

def char_to_num(x):
  return ord(x) - ord('a')

for i in range(N):
  ok = True
  for j in range(len(S[i]) - 1):
    if S[i][j] > S[i][j + 1]:
      ok = False
      break
  if not ok:
    continue
      
  start = char_to_num(S[i][0])
  end = char_to_num(S[i][-1])
  length = len(S[i])
  
  dp[end] = max(dp[end], max(dp[:start + 1]) + length)
  
print(max(dp))
  



0