結果
問題 | No.2693 Sword |
ユーザー |
![]() |
提出日時 | 2024-03-22 21:56:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 813 bytes |
コンパイル時間 | 226 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 67,456 KB |
最終ジャッジ日時 | 2024-09-30 11:25:16 |
合計ジャッジ時間 | 2,319 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
N,P,K=map(int,input().split())counttwo=0ones=[]dat=[]for _ in range(N):t,b=map(int,input().split())if t==2:counttwo+=1else:ones.append(b)dat.append([t,b])ones.sort(reverse=True)ans=0for i in range(min(counttwo+1,K+1)):use=K-iif len(ones)>=use:lis=[]mul=1twocount=0count=0for j in range(N-1,-1,-1):if dat[j][0]==2:if twocount<i:mul*=2twocount+=1if mul>10**18:mul=10**18+1else: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)