結果

問題 No.2686 商品券の使い道
ユーザー titiatitia
提出日時 2024-03-26 04:08:21
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 896 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 110,020 KB
最終ジャッジ日時 2024-03-26 04:08:39
合計ジャッジ時間 16,691 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 105 ms
72,344 KB
testcase_03 AC 113 ms
75,548 KB
testcase_04 AC 110 ms
74,268 KB
testcase_05 AC 118 ms
73,112 KB
testcase_06 AC 106 ms
73,112 KB
testcase_07 AC 105 ms
72,604 KB
testcase_08 AC 102 ms
72,344 KB
testcase_09 AC 104 ms
72,604 KB
testcase_10 AC 107 ms
73,628 KB
testcase_11 AC 1,517 ms
85,172 KB
testcase_12 AC 496 ms
82,288 KB
testcase_13 AC 213 ms
109,936 KB
testcase_14 AC 1,999 ms
84,492 KB
testcase_15 AC 466 ms
75,808 KB
testcase_16 AC 1,227 ms
93,088 KB
testcase_17 AC 365 ms
75,808 KB
testcase_18 AC 214 ms
92,708 KB
testcase_19 AC 447 ms
92,596 KB
testcase_20 AC 140 ms
110,020 KB
testcase_21 AC 2,135 ms
99,772 KB
testcase_22 AC 179 ms
75,808 KB
testcase_23 AC 627 ms
79,220 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
evil_random20_1.txt -- -
evil_random20_2.txt -- -
evil_random20_3.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

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

LIST1=[]
LIST2=[]

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:
        LIST1.append(i)
    if c<=Q:
        LIST2.append(i)

LIST=[]
for x in LIST1[::-1]:
    flag=1
    for y in LIST:
        if x|y==y:
            flag=0
            break
    if flag==1:
        LIST.append(x)

LIST1=LIST

LIST=[]
for x in LIST2[::-1]:
    flag=1
    for y in LIST:
        if x|y==y:
            flag=0
            break
    if flag==1:
        LIST.append(x)

LIST2=LIST

ANS=0
for x in LIST1:
    for y in LIST2:
        z=x|y
        score=0

        for i in range(N):
            if z & (1<<i) !=0:
                score+=AB[i][1]
        ANS=max(ANS,score)

print(ANS)
0