結果

問題 No.2329 Nafmo、イカサマをする
ユーザー vwxyzvwxyz
提出日時 2023-09-10 21:32:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,588 ms / 2,000 ms
コード長 1,192 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 86,312 KB
実行使用メモリ 152,968 KB
最終ジャッジ日時 2023-09-10 21:32:40
合計ジャッジ時間 18,308 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 260 ms
92,860 KB
testcase_01 AC 299 ms
97,476 KB
testcase_02 AC 259 ms
93,132 KB
testcase_03 AC 259 ms
92,984 KB
testcase_04 AC 259 ms
93,004 KB
testcase_05 AC 260 ms
93,132 KB
testcase_06 AC 261 ms
92,936 KB
testcase_07 AC 261 ms
92,896 KB
testcase_08 AC 317 ms
97,272 KB
testcase_09 AC 261 ms
93,040 KB
testcase_10 AC 262 ms
92,780 KB
testcase_11 AC 263 ms
92,744 KB
testcase_12 AC 276 ms
95,444 KB
testcase_13 AC 266 ms
93,148 KB
testcase_14 AC 261 ms
93,168 KB
testcase_15 AC 260 ms
93,264 KB
testcase_16 AC 294 ms
96,368 KB
testcase_17 AC 261 ms
92,768 KB
testcase_18 AC 281 ms
96,656 KB
testcase_19 AC 305 ms
96,932 KB
testcase_20 AC 335 ms
97,720 KB
testcase_21 AC 307 ms
97,132 KB
testcase_22 AC 323 ms
97,364 KB
testcase_23 AC 262 ms
92,776 KB
testcase_24 AC 258 ms
93,176 KB
testcase_25 AC 279 ms
96,800 KB
testcase_26 AC 259 ms
92,772 KB
testcase_27 AC 256 ms
93,064 KB
testcase_28 AC 259 ms
93,184 KB
testcase_29 AC 356 ms
98,016 KB
testcase_30 AC 297 ms
97,088 KB
testcase_31 AC 261 ms
92,960 KB
testcase_32 AC 299 ms
97,072 KB
testcase_33 AC 262 ms
92,768 KB
testcase_34 AC 260 ms
92,768 KB
testcase_35 AC 314 ms
96,852 KB
testcase_36 AC 857 ms
121,604 KB
testcase_37 AC 290 ms
96,568 KB
testcase_38 AC 261 ms
92,976 KB
testcase_39 AC 899 ms
124,048 KB
testcase_40 AC 309 ms
97,808 KB
testcase_41 AC 1,588 ms
152,968 KB
testcase_42 AC 307 ms
97,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')

N,M,K=map(int,readline().split())
A=list(map(int,readline().split()))
se=set()
for tpl in itertools.product(A,repeat=K//2):
    for i in range(K//2+1):
        se.add(sum(tpl[:i]))
lst=list(se)
lst.sort()
ans=0
se=set()
for tpl in itertools.product(A,repeat=K-K//2):
    for i in range((K-K//2)+1):
        a=sum(tpl[:i])
        se.add(a)
for a in se:
    i=bisect.bisect_right(lst,M-a)
    if i:
        ans=max(ans,a+lst[i-1])
print(ans)
0