結果
問題 | No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia |
ユーザー | Hydru |
提出日時 | 2021-10-29 22:23:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 542 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 82,604 KB |
実行使用メモリ | 847,896 KB |
最終ジャッジ日時 | 2024-04-16 15:13:36 |
合計ジャッジ時間 | 4,904 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
51,968 KB |
testcase_01 | AC | 38 ms
52,352 KB |
testcase_02 | AC | 38 ms
52,736 KB |
testcase_03 | AC | 38 ms
52,096 KB |
testcase_04 | AC | 38 ms
52,324 KB |
testcase_05 | AC | 38 ms
51,840 KB |
testcase_06 | AC | 38 ms
52,736 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 52 ms
63,872 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 | -- | - |
ソースコード
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="" 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] print(ans[::-1])