結果

問題 No.2329 Nafmo、イカサマをする
ユーザー Akijin_007Akijin_007
提出日時 2023-09-01 14:04:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 377 ms / 2,000 ms
コード長 846 bytes
コンパイル時間 692 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 104,616 KB
最終ジャッジ日時 2023-09-01 14:05:02
合計ジャッジ時間 8,171 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,180 KB
testcase_01 AC 73 ms
76,484 KB
testcase_02 AC 67 ms
71,564 KB
testcase_03 AC 67 ms
71,528 KB
testcase_04 AC 70 ms
71,176 KB
testcase_05 AC 68 ms
71,312 KB
testcase_06 AC 69 ms
75,284 KB
testcase_07 AC 66 ms
71,496 KB
testcase_08 AC 91 ms
76,592 KB
testcase_09 AC 75 ms
76,316 KB
testcase_10 AC 70 ms
71,508 KB
testcase_11 AC 76 ms
76,236 KB
testcase_12 AC 73 ms
76,352 KB
testcase_13 AC 73 ms
76,404 KB
testcase_14 AC 66 ms
71,380 KB
testcase_15 AC 67 ms
71,172 KB
testcase_16 AC 72 ms
76,408 KB
testcase_17 AC 68 ms
71,304 KB
testcase_18 AC 78 ms
76,944 KB
testcase_19 AC 118 ms
80,136 KB
testcase_20 AC 105 ms
78,060 KB
testcase_21 AC 126 ms
80,540 KB
testcase_22 AC 90 ms
77,396 KB
testcase_23 AC 78 ms
76,532 KB
testcase_24 AC 68 ms
71,508 KB
testcase_25 AC 88 ms
77,000 KB
testcase_26 AC 69 ms
71,512 KB
testcase_27 AC 73 ms
76,628 KB
testcase_28 AC 72 ms
75,052 KB
testcase_29 AC 100 ms
77,664 KB
testcase_30 AC 83 ms
77,088 KB
testcase_31 AC 75 ms
71,492 KB
testcase_32 AC 75 ms
76,516 KB
testcase_33 AC 75 ms
76,532 KB
testcase_34 AC 75 ms
76,396 KB
testcase_35 AC 83 ms
77,272 KB
testcase_36 AC 194 ms
88,008 KB
testcase_37 AC 102 ms
77,148 KB
testcase_38 AC 76 ms
76,480 KB
testcase_39 AC 370 ms
104,616 KB
testcase_40 AC 336 ms
104,188 KB
testcase_41 AC 377 ms
103,920 KB
testcase_42 AC 329 ms
103,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))

N, M, K = map(int, input().split())
A = list(map(int, input().split()))

from itertools import product
from bisect import bisect_right

ans = 0

if 1 <= K <= 3:
    for i in range(K):
        for x in product(A, repeat=i+1):
            s = sum(x)
            if s <= M:
                ans = max(ans, s)
else:
    A.append(0)
    s2 = set()
    s3 = set()
    for i in range(3):
        for x in product(A, repeat=i+1):
            s = sum(x)
            if i < 2:
                s2.add(s)
            if i < 3:
                s3.add(s)

    if K == 4:
        u = A
    elif K == 5:
        u = s2
    else:
        u = s3

    s3 = sorted(s3)
    for x in u:
        t = bisect_right(s3, M-x)
        if t != 0:
            ans = max(ans, x+s3[t-1])

print(ans)




0