結果

問題 No.1512 作文
ユーザー kozykozy
提出日時 2021-05-21 21:46:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 667 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 76,016 KB
最終ジャッジ日時 2024-04-18 15:02:26
合計ジャッジ時間 7,233 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
18,080 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 33 ms
10,880 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

L=list()
N=int(input())
for i in range(N):
  S=input()
  if len(S)==1:
    L.append((ord(S[0])-97,ord(S[-1])-97,1))
  for j in range(1,len(S)):
    if S[j-1]>S[j]:
      break
    if j==len(S)-1:
      L.append((ord(S[0])-97,ord(S[-1])-97,len(S)))
N=len(L)
L.sort()
#i番目までの数字でjで終わる奴の個数の最大dp[i][j]
dp=[[0]*26 for i in range(N+1)]
maxs=[[0]*26 for i in range(N+1)]
for i in range(1,N+1):
  a,b,c=L[i-1]
  for j in range(26):
    if j==b:
      dp[i][j]=max(dp[i-1][j],maxs[i-1][a]+c)
    else:
      dp[i][j]=dp[i-1][j]
    if j!=0:
      maxs[i][j]=max(maxs[i][j-1],dp[i][j])
    else:
      maxs[i][j]=dp[i][j]
print(max(dp[-1]))
0