結果

問題 No.2686 商品券の使い道
ユーザー mymelochanmymelochan
提出日時 2024-03-20 22:44:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,011 ms / 3,000 ms
コード長 1,063 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 84,064 KB
最終ジャッジ日時 2024-03-20 22:45:11
合計ジャッジ時間 28,806 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,724 KB
testcase_01 AC 43 ms
55,724 KB
testcase_02 AC 241 ms
77,912 KB
testcase_03 AC 241 ms
77,912 KB
testcase_04 AC 243 ms
77,912 KB
testcase_05 AC 239 ms
77,912 KB
testcase_06 AC 242 ms
77,912 KB
testcase_07 AC 231 ms
77,900 KB
testcase_08 AC 241 ms
77,912 KB
testcase_09 AC 241 ms
77,912 KB
testcase_10 AC 241 ms
77,912 KB
testcase_11 AC 238 ms
77,920 KB
testcase_12 AC 237 ms
77,920 KB
testcase_13 AC 242 ms
77,916 KB
testcase_14 AC 237 ms
77,920 KB
testcase_15 AC 245 ms
77,920 KB
testcase_16 AC 240 ms
77,920 KB
testcase_17 AC 238 ms
77,920 KB
testcase_18 AC 239 ms
77,916 KB
testcase_19 AC 246 ms
77,916 KB
testcase_20 AC 236 ms
77,904 KB
testcase_21 AC 239 ms
77,920 KB
testcase_22 AC 238 ms
77,920 KB
testcase_23 AC 245 ms
77,912 KB
testcase_24 AC 245 ms
77,920 KB
testcase_25 AC 247 ms
77,920 KB
testcase_26 AC 239 ms
77,920 KB
testcase_27 AC 244 ms
77,920 KB
testcase_28 AC 235 ms
77,904 KB
testcase_29 AC 1,008 ms
84,064 KB
testcase_30 AC 953 ms
84,060 KB
testcase_31 AC 949 ms
84,064 KB
testcase_32 AC 965 ms
84,052 KB
testcase_33 AC 941 ms
84,064 KB
testcase_34 AC 975 ms
84,060 KB
testcase_35 AC 975 ms
84,064 KB
testcase_36 AC 957 ms
84,060 KB
testcase_37 AC 969 ms
84,060 KB
testcase_38 AC 947 ms
84,060 KB
testcase_39 AC 1,006 ms
84,064 KB
testcase_40 AC 948 ms
84,064 KB
testcase_41 AC 940 ms
84,060 KB
testcase_42 AC 1,011 ms
84,064 KB
testcase_43 AC 947 ms
84,064 KB
testcase_44 AC 997 ms
84,064 KB
testcase_45 AC 978 ms
84,064 KB
testcase_46 AC 1,010 ms
84,064 KB
evil_random20_1.txt AC 965 ms
84,060 KB
evil_random20_2.txt AC 933 ms
84,060 KB
evil_random20_3.txt AC 786 ms
84,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#############################################################

import sys
sys.setrecursionlimit(10**7)

from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from bisect import bisect_left, bisect_right
from itertools import product,combinations,permutations

ipt = sys.stdin.readline

def iin():
    return int(ipt())
def lmin():
    return list(map(int,ipt().split()))

MOD = 998244353
#############################################################

N,M,Q = lmin()
L = [lmin() for _ in range(N)]
pre = [0]*(1<<N)
for i in range(1,1<<N):
    v = 0
    p = 0
    for j in range(N):
        if i&(1<<j):
            v += L[j][1]
            p += L[j][0]
    
    if p <= Q:
        pre[i] = v
    
    for j in range(N):
        if not i&(1<<j):
            pre[i^(1<<j)] = max(pre[i^(1<<j)], pre[i])


ans = 0
for i in range(1<<N):
    v,p = 0,0
    for j in range(N):
        if i&(1<<j):
            v += L[j][1]
            p += L[j][0]
    
    if p <= M:
        c = ((1<<N)-1)^i
        ans = max(ans,v+pre[c])

print(ans)
    
0