結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー HydruHydru
提出日時 2021-10-29 22:40:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 605 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 847,968 KB
最終ジャッジ日時 2024-04-16 15:28:54
合計ジャッジ時間 5,225 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,312 KB
testcase_01 AC 38 ms
52,876 KB
testcase_02 AC 38 ms
52,160 KB
testcase_03 AC 38 ms
53,360 KB
testcase_04 AC 38 ms
52,568 KB
testcase_05 AC 38 ms
52,236 KB
testcase_06 AC 38 ms
53,088 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 51 ms
64,092 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()))
inf=10**9+1
dp=[[0]*(k+1) for _ in range(n+1)]
for i in range(1,n+1):
    dp[i][0]=dp[i-1][0]+B[i-1]
for i in range(1,k+1):
    dp[0][i]=-inf
for i in range(1,n+1):
    for j in range(1,k+1):
        dp[i][j]=max(dp[i-1][j]+B[i-1],dp[i-1][j-1]+A[i-1])

ind=k
val=dp[n][k]
ans=""
tmp=0
for i in range(n-1,-1,-1):
    if val==dp[i][ind-1]+A[i]:
        ans+="A"
        ind-=1
        val-=A[i]
    else:
        ans+="B"
        val-=B[i]
    if ind==0:
        tmp=i
        break
ans+="B"*tmp
print(ans[::-1])
0