結果

問題 No.2686 商品券の使い道
ユーザー titiatitia
提出日時 2024-03-27 01:57:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 678 ms / 3,000 ms
コード長 698 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 91,980 KB
最終ジャッジ日時 2024-03-27 01:58:16
合計ジャッジ時間 20,274 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 185 ms
79,788 KB
testcase_03 AC 162 ms
79,804 KB
testcase_04 AC 162 ms
79,796 KB
testcase_05 AC 161 ms
79,788 KB
testcase_06 AC 160 ms
79,788 KB
testcase_07 AC 156 ms
79,668 KB
testcase_08 AC 159 ms
79,788 KB
testcase_09 AC 183 ms
79,804 KB
testcase_10 AC 160 ms
79,796 KB
testcase_11 AC 157 ms
79,680 KB
testcase_12 AC 165 ms
79,684 KB
testcase_13 AC 157 ms
79,676 KB
testcase_14 AC 162 ms
79,680 KB
testcase_15 AC 160 ms
79,680 KB
testcase_16 AC 169 ms
79,684 KB
testcase_17 AC 165 ms
79,680 KB
testcase_18 AC 161 ms
79,676 KB
testcase_19 AC 166 ms
79,684 KB
testcase_20 AC 151 ms
79,660 KB
testcase_21 AC 158 ms
79,680 KB
testcase_22 AC 162 ms
79,680 KB
testcase_23 AC 165 ms
79,796 KB
testcase_24 AC 155 ms
79,680 KB
testcase_25 AC 165 ms
79,684 KB
testcase_26 AC 163 ms
79,684 KB
testcase_27 AC 157 ms
79,668 KB
testcase_28 AC 153 ms
79,668 KB
testcase_29 AC 678 ms
91,976 KB
testcase_30 AC 627 ms
91,836 KB
testcase_31 AC 632 ms
91,976 KB
testcase_32 AC 603 ms
91,968 KB
testcase_33 AC 651 ms
91,836 KB
testcase_34 AC 596 ms
91,840 KB
testcase_35 AC 658 ms
91,836 KB
testcase_36 AC 623 ms
91,968 KB
testcase_37 AC 640 ms
91,980 KB
testcase_38 AC 609 ms
91,968 KB
testcase_39 AC 616 ms
91,980 KB
testcase_40 AC 672 ms
91,976 KB
testcase_41 AC 616 ms
91,948 KB
testcase_42 AC 670 ms
91,976 KB
testcase_43 AC 623 ms
91,980 KB
testcase_44 AC 650 ms
91,980 KB
testcase_45 AC 648 ms
91,976 KB
testcase_46 AC 638 ms
91,980 KB
evil_random20_1.txt AC 628 ms
91,948 KB
evil_random20_2.txt AC 638 ms
91,948 KB
evil_random20_3.txt AC 614 ms
91,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from operator import itemgetter

N,M,Q=map(int,input().split())

AB=[list(map(int,input().split())) for i in range(N)]

DP=[0 for i in range(1<<N)]
DP2=[0 for i in range(1<<N)]

for i in range(1<<N):
    c=0
    v=0
    for j in range(N):
        if i & (1<<j) != 0:
            c+=AB[j][0]
            v+=AB[j][1]

    if c<=M:
        DP[i]=v
    if c<=Q:
        DP2[i]=v

#print(DP)
#print(DP2)

for i in range(N):
    for j in range(1<<N):
        if j & (1<<i) != 0:
            DP[j]=max(DP[j],DP[j^(1<<i)])
            DP2[j]=max(DP2[j],DP2[j^(1<<i)])
                
ANS=0

for i in range(1<<N):
    ANS=max(ANS,DP[i]+DP2[((1<<N)-1)^i])

print(ANS)
0