結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 40 ms
51,840 KB
testcase_02 AC 38 ms
52,096 KB
testcase_03 AC 38 ms
51,840 KB
testcase_04 AC 39 ms
52,280 KB
testcase_05 AC 39 ms
52,480 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 100 ms
110,336 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 #

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

dp = [[-1000010000]*(k+1) for _ in range(n+1)]
ans = [['0']*(k+1) for _ in range(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'

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