結果

問題 No.2693 Sword
ユーザー tohohogisu
提出日時 2024-02-08 17:16:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 384 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 82,264 KB
実行使用メモリ 83,124 KB
最終ジャッジ日時 2024-09-28 12:59:53
合計ジャッジ時間 4,046 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 5 TLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

MAX = 10 ** 18
n,p,k = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
ans = p
for BIT in range(2 ** n):
	bit = bin(BIT)[2:].zfill(n)
	if bit.count("1") != k:
		continue
	cnt = p
	for i in range(n):
		if bit[i] == "1":
			if a[i][0] == 1:
				cnt += a[i][1]
			else:
				cnt *= 2
		if cnt > MAX:
			print(-1)
			exit()
	ans = max(ans, cnt)
print(ans)
0