結果

問題 No.2329 Nafmo、イカサマをする
ユーザー cozy_saunacozy_sauna
提出日時 2023-05-28 15:06:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 2,758 bytes
コンパイル時間 1,726 ms
コンパイル使用メモリ 86,328 KB
実行使用メモリ 107,440 KB
最終ジャッジ日時 2023-08-27 11:25:02
合計ジャッジ時間 13,278 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 252 ms
91,476 KB
testcase_01 AC 250 ms
91,916 KB
testcase_02 AC 251 ms
91,400 KB
testcase_03 AC 256 ms
91,820 KB
testcase_04 AC 249 ms
91,576 KB
testcase_05 AC 257 ms
91,796 KB
testcase_06 AC 251 ms
91,720 KB
testcase_07 AC 253 ms
91,880 KB
testcase_08 AC 256 ms
92,368 KB
testcase_09 AC 249 ms
91,504 KB
testcase_10 AC 254 ms
91,896 KB
testcase_11 AC 247 ms
91,604 KB
testcase_12 AC 246 ms
91,572 KB
testcase_13 AC 249 ms
91,932 KB
testcase_14 AC 252 ms
91,908 KB
testcase_15 AC 255 ms
91,796 KB
testcase_16 AC 250 ms
91,900 KB
testcase_17 AC 254 ms
91,844 KB
testcase_18 AC 256 ms
91,840 KB
testcase_19 AC 264 ms
94,492 KB
testcase_20 AC 252 ms
92,232 KB
testcase_21 AC 255 ms
92,368 KB
testcase_22 AC 257 ms
92,516 KB
testcase_23 AC 255 ms
92,236 KB
testcase_24 AC 251 ms
91,796 KB
testcase_25 AC 254 ms
92,176 KB
testcase_26 AC 257 ms
92,000 KB
testcase_27 AC 257 ms
92,164 KB
testcase_28 AC 256 ms
91,732 KB
testcase_29 AC 279 ms
94,536 KB
testcase_30 AC 259 ms
92,024 KB
testcase_31 AC 256 ms
91,892 KB
testcase_32 AC 257 ms
92,084 KB
testcase_33 AC 259 ms
92,024 KB
testcase_34 AC 258 ms
92,128 KB
testcase_35 AC 258 ms
92,356 KB
testcase_36 AC 278 ms
94,856 KB
testcase_37 AC 260 ms
92,520 KB
testcase_38 AC 268 ms
92,036 KB
testcase_39 AC 280 ms
96,732 KB
testcase_40 AC 271 ms
94,812 KB
testcase_41 AC 342 ms
107,440 KB
testcase_42 AC 270 ms
94,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit, stdin
from collections import defaultdict, deque, Counter
from itertools import permutations, combinations, product
from functools import lru_cache
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop
from copy import copy, deepcopy
from decimal import Decimal
from random import random, randrange

# from pypyjit import set_param
# set_param('max_unroll_recursion=-1')

setrecursionlimit(1 << 20)
readline = stdin.readline
INF = 10 ** 18
MOD = 998244353
# MOD = 1000000007
ALP = 26
''' Input '''
def I(): return int(readline())
def ST(): return readline()[:-1]
def LI(): return list(map(int, readline().split()))
def LII(): return list(map(lambda x: int(x) - 1, readline().split()))
def LF(x, func): return [func() for _ in [0] * x]
def SPI(): return map(int, readline().split())
def SPII(): return map(lambda x: int(x) - 1, readline().split())
def FIE(x): return [readline()[:-1] for _ in [0] * x]

''' Array '''
def cmin(dp, i, x):
    if x < dp[i]: dp[i] = x
def cmax(dp, i, x):
    if x > dp[i]: dp[i] = x

''' Alphabet '''
def alp_a_to_i(s): return ord(s) - ord('a')
def alp_A_to_i(s): return ord(s) - ord('A')
def alp_i_to_a(i): return chr(ord('a') + i)
def alp_i_to_A(i): return chr(ord('A') + i)

''' Other'''
def nynx(y, x, H, W): return [(y + dy, x + dx) for dy, dx in [(-1, 0), (1, 0), (0, -1), (0, 1)] if 0 <= y + dy < H and 0 <= x + dx < W]
def gen(x, *args):
    if len(args) == 1: return [x] * args[0]
    if len(args) == 2: return [[x] * args[1] for _ in [0] * args[0]]
    if len(args) == 3: return [[[x] * args[2] for _ in [0] * args[1]] for _ in [0] * args[0]]
    if len(args) == 4: return [[[[x] * args[3] for _ in [0] * args[2]] for _ in [0] * args[1]] for _ in [0] * args[0]]

''' Output '''
def pprint(E): 
    print()
    for e in E: print(e)
def Yes(): print("Yes")
def No(): print("No")
def YES(): print("YES")
def NO(): print("NO")
def yn(x): print("Yes" if x else "No")
def YN(x): print("YES" if x else "NO")
###############################################################################################

N, M, K = SPI()
A = LI()

def f(x): # x <= 3
    now = set([0])
    for _ in range(x):
        for e in copy(now):
            for a in A:
                if e + a <= M:
                    now.add(e + a)

    return list(sorted(now))


if K <= 2:
    ans = max(f(K))
    print(ans)
else:
    ONE = f(K // 2)
    TWO = f(K - K // 2)
    ans = 0
    for a in ONE:
        if a > M: break
        ok = 0
        ng = len(TWO)
        while ng - ok > 1:
            mid = ok + ng >> 1
            if a + TWO[mid] <= M:
                ok = mid
            else: 
                ng = mid
        # print(a, ok)
        ans = max(ans, a + TWO[ok])
    print(ans)
0