結果

問題 No.2686 商品券の使い道
ユーザー とりゐとりゐ
提出日時 2024-03-20 22:37:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 564 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 83,652 KB
最終ジャッジ日時 2024-03-20 22:37:44
合計ジャッジ時間 18,478 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 214 ms
77,508 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 168 ms
77,508 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 168 ms
77,512 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 163 ms
77,504 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 537 ms
83,652 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 517 ms
83,652 KB
testcase_34 AC 557 ms
83,652 KB
testcase_35 AC 536 ms
83,652 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
evil_random20_1.txt WA -
evil_random20_2.txt WA -
evil_random20_3.txt WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,q=map(int,input().split())
ab=[]
for i in range(n):
  a,b=map(int,input().split())
  ab.append([a,b])

dp=[0]*(1<<n)
for bit in range(1<<n):
  cost=0
  val=0
  for i in range(n):
    if (bit>>i)&1:
      cost+=ab[i][0]
      val+=ab[i][1]
  if cost<=m:
    dp[bit]=val
  for i in range(n):
    if (bit>>i)&1==0:
      dp[bit|(1<<i)]=max(dp[bit|(1<<i)],dp[bit])

mask=(1<<n)-1
ans=0
for bit in range(n):
  cost=0
  val=0
  for i in range(n):
    if (bit>>i)&1:
      cost+=ab[i][0]
      val+=ab[i][1]
  if cost<=q:
    ans=max(ans,val+dp[bit^mask])

print(ans)
0