結果

問題 No.1512 作文
ユーザー O2MTO2MT
提出日時 2021-05-21 23:24:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 584 bytes
コンパイル時間 412 ms
コンパイル使用メモリ 82,264 KB
実行使用メモリ 180,428 KB
最終ジャッジ日時 2024-04-18 16:55:17
合計ジャッジ時間 5,839 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 35 ms
53,620 KB
testcase_02 AC 36 ms
52,068 KB
testcase_03 AC 36 ms
53,832 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 41 ms
63,520 KB
testcase_10 AC 53 ms
65,536 KB
testcase_11 AC 51 ms
64,316 KB
testcase_12 AC 51 ms
65,592 KB
testcase_13 AC 46 ms
64,296 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 41 ms
55,076 KB
testcase_22 AC 38 ms
53,684 KB
testcase_23 AC 39 ms
54,080 KB
testcase_24 AC 37 ms
56,120 KB
testcase_25 WA -
testcase_26 AC 37 ms
52,956 KB
testcase_27 AC 34 ms
52,420 KB
testcase_28 AC 34 ms
52,548 KB
testcase_29 AC 34 ms
52,432 KB
testcase_30 AC 35 ms
53,252 KB
testcase_31 AC 35 ms
52,876 KB
testcase_32 AC 39 ms
59,644 KB
testcase_33 AC 36 ms
53,580 KB
testcase_34 AC 45 ms
64,016 KB
testcase_35 AC 59 ms
82,064 KB
testcase_36 AC 55 ms
82,144 KB
testcase_37 AC 42 ms
68,160 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 461 ms
175,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = [list(str(input())) for _ in range(N)]
def getIndex(s):
  return ord(s)-96

l = []
for i in range(N):
  a,b = getIndex(S[i][0]),getIndex(S[i][-1])
  if a <= b:
    r = sorted(S[i])
    if S[i] == r:
      l.append((a,b,len(S[i])))

N = len(l)

dp = [[0 for _ in range(27)] for _ in range(N+1)]
for i in range(N):
  a,b,c = l[i]
  for j in range(27):
    dp[i+1][j] = max(dp[i][j], dp[i+1][j])
  for j in range(a+1):
    dp[i+1][b] = max(dp[i][j]+c, dp[i][b],dp[i+1][b])
  
ans = 0
for i in range(N+1):
  for j in range(27):
    ans = max(ans,dp[i][j])

print(ans)
0