結果

問題 No.1512 作文
ユーザー kozykozy
提出日時 2021-05-21 21:46:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 732 ms / 2,000 ms
コード長 667 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 82,100 KB
実行使用メモリ 210,624 KB
最終ジャッジ日時 2024-04-18 15:02:48
合計ジャッジ時間 7,479 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 39 ms
52,096 KB
testcase_02 AC 38 ms
51,712 KB
testcase_03 AC 39 ms
52,096 KB
testcase_04 AC 506 ms
145,556 KB
testcase_05 AC 503 ms
145,168 KB
testcase_06 AC 506 ms
145,280 KB
testcase_07 AC 500 ms
145,276 KB
testcase_08 AC 501 ms
145,692 KB
testcase_09 AC 39 ms
53,760 KB
testcase_10 AC 40 ms
53,248 KB
testcase_11 AC 39 ms
53,248 KB
testcase_12 AC 40 ms
53,376 KB
testcase_13 AC 40 ms
53,248 KB
testcase_14 AC 116 ms
77,084 KB
testcase_15 AC 135 ms
77,440 KB
testcase_16 AC 115 ms
77,020 KB
testcase_17 AC 106 ms
76,672 KB
testcase_18 AC 112 ms
77,056 KB
testcase_19 AC 113 ms
77,056 KB
testcase_20 AC 110 ms
77,056 KB
testcase_21 AC 39 ms
52,864 KB
testcase_22 AC 39 ms
52,096 KB
testcase_23 AC 40 ms
52,864 KB
testcase_24 AC 41 ms
52,864 KB
testcase_25 AC 41 ms
53,196 KB
testcase_26 AC 38 ms
51,968 KB
testcase_27 AC 38 ms
52,480 KB
testcase_28 AC 39 ms
52,096 KB
testcase_29 AC 39 ms
51,840 KB
testcase_30 AC 39 ms
51,840 KB
testcase_31 AC 44 ms
58,368 KB
testcase_32 AC 45 ms
58,752 KB
testcase_33 AC 44 ms
58,496 KB
testcase_34 AC 57 ms
62,720 KB
testcase_35 AC 61 ms
71,680 KB
testcase_36 AC 47 ms
71,680 KB
testcase_37 AC 46 ms
66,048 KB
testcase_38 AC 57 ms
75,392 KB
testcase_39 AC 63 ms
76,032 KB
testcase_40 AC 732 ms
205,972 KB
testcase_41 AC 471 ms
210,624 KB
権限があれば一括ダウンロードができます

ソースコード

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