結果
問題 | No.2693 Sword |
ユーザー |
![]() |
提出日時 | 2024-03-22 22:12:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 150 ms / 2,000 ms |
コード長 | 1,730 bytes |
コンパイル時間 | 351 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 78,672 KB |
最終ジャッジ日時 | 2024-09-30 11:41:53 |
合計ジャッジ時間 | 2,840 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
N,P,K = map(int,input().split()) d1,d2 = {},{} d1[0] = P for i in range(N): T,B = map(int,input().split()) if len(d1): for ind,val in d1.items(): if ind not in d2: d2[ind] = val else: d2[ind] = max(d2[ind],val) if T == 1: nex = val+B if ind+1 <= K: if ind+1 not in d2: d2[ind+1] = nex else: d2[ind+1] = max(d2[ind+1],nex) else: nex = val*2 if ind+1 <= K: if ind+1 not in d2: d2[ind+1] = nex else: d2[ind+1] = max(d2[ind+1],nex) if K in d2: if d2[K] > 10**18: print(-1) exit() d1 = {} else: for ind,val in d2.items(): if ind not in d1: d1[ind] = val else: d1[ind] = max(d1[ind],val) if T == 1: nex = val+B if ind+1 <= K: if ind+1 not in d1: d1[ind+1] = nex else: d1[ind+1] = max(d1[ind+1],nex) else: nex = val*2 if ind+1 <= K: if ind+1 not in d1: d1[ind+1] = nex else: d1[ind+1] = max(d1[ind+1],nex) if K in d1: if d1[K] > 10**18: print(-1) exit() d2 = {} if len(d1): print(d1[K]) else: print(d2[K])