結果
問題 |
No.2693 Sword
|
ユーザー |
![]() |
提出日時 | 2024-03-22 21:52:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 740 bytes |
コンパイル時間 | 301 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 66,688 KB |
最終ジャッジ日時 | 2024-09-30 11:21:29 |
合計ジャッジ時間 | 2,874 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 WA * 9 |
ソースコード
N,P,K=map(int,input().split()) counttwo=0 ones=[] dat=[] for _ in range(N): t,b=map(int,input().split()) if t==2: counttwo+=1 else: ones.append(b) dat.append([t,b]) ones.sort(reverse=True) ans=0 for i in range(min(counttwo+1,K)): use=K-i if len(ones)>=use: lis=[] mul=1 twocount=0 count=0 for j in range(N-1,-1,-1): if dat[j][0]==2: if twocount<i: mul*=2 twocount+=1 else: lis.append(mul*dat[j][1]) lis.sort(reverse=True) tmp=P*mul+sum(lis[:use]) if tmp>=10**18: print(-1) exit(0) ans=max(ans,tmp) print(ans)