結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー mesame3993mesame3993
提出日時 2021-10-29 23:02:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 613 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 82,224 KB
実行使用メモリ 848,180 KB
最終ジャッジ日時 2024-04-16 15:43:05
合計ジャッジ時間 5,040 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,608 KB
testcase_01 AC 41 ms
51,968 KB
testcase_02 AC 41 ms
51,840 KB
testcase_03 AC 43 ms
52,352 KB
testcase_04 AC 42 ms
52,156 KB
testcase_05 AC 41 ms
52,096 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 97 ms
101,248 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 MLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  n, k = map(int, input().split())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  if k > n//2:
    A,B=B,A 
    k=n-k

  dp=[[-1000010000]*(k+1) for _ in [0]*(n+1)]
  ans=[['0']*(k+1) for _ in [0]*(n+1)]
  dp[0][0]=0
  for i in range(n):
    for j in range(k+1):
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]+B[i])
      if j<=k and j>0:
        dp[i+1][j]=max(dp[i+1][j], dp[i][j-1]+A[i])
      if dp[i+1][j]==dp[i][j]+B[i]:
        ans[i+1][j]=ans[i][j]+'B'
      else:
        ans[i+1][j]=ans[i][j-1]+'A'
    if i-2>0:
      ans[i-2]=[]

  print(ans[-1][-1][1:])
main()
0