結果
問題 | No.2329 Nafmo、イカサマをする |
ユーザー |
|
提出日時 | 2023-05-28 15:04:11 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,906 bytes |
コンパイル時間 | 225 ms |
コンパイル使用メモリ | 81,988 KB |
実行使用メモリ | 155,688 KB |
最終ジャッジ日時 | 2024-12-27 04:23:57 |
合計ジャッジ時間 | 7,858 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 WA * 6 |
ソースコード
from sys import setrecursionlimit, stdinfrom collections import defaultdict, deque, Counterfrom itertools import permutations, combinations, productfrom functools import lru_cachefrom bisect import bisect_left, bisect_rightfrom heapq import heappush, heappopfrom copy import copy, deepcopyfrom decimal import Decimalfrom random import random, randrange# from pypyjit import set_param# set_param('max_unroll_recursion=-1')setrecursionlimit(1 << 20)readline = stdin.readlineINF = 10 ** 18MOD = 998244353# MOD = 1000000007ALP = 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] = xdef 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 <= 3now = set([0])for _ in range(x):for e in copy(now):for a in A:now.add(e + a)return list(sorted(now))if K <= 1:ans = 0for a in A:if a <= M:ans = max(ans, a)elif K == 2:ans = 0for a in A:for b in A:if a + b <= M:ans = max(ans, a + b)print(ans)else:ONE = f(K // 2)TWO = f(K - K // 2)ans = 0for a in ONE:if a > M: breakok = 0ng = len(TWO)while ng - ok > 1:mid = ok + ng >> 1if a + TWO[mid] <= M:ok = midelse:ng = mid# print(a, ok)ans = max(ans, a + TWO[ok])print(ans)