結果

問題 No.733 分身並列コーディング
ユーザー mkawa2mkawa2
提出日時 2021-01-28 16:28:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 415 ms / 1,500 ms
コード長 1,293 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 102,684 KB
最終ジャッジ日時 2023-09-08 07:19:47
合計ジャッジ時間 14,433 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,724 KB
testcase_01 AC 74 ms
70,888 KB
testcase_02 AC 78 ms
70,848 KB
testcase_03 AC 313 ms
91,388 KB
testcase_04 AC 391 ms
102,684 KB
testcase_05 AC 268 ms
90,096 KB
testcase_06 AC 72 ms
71,084 KB
testcase_07 AC 303 ms
92,624 KB
testcase_08 AC 282 ms
92,532 KB
testcase_09 AC 286 ms
84,620 KB
testcase_10 AC 160 ms
78,292 KB
testcase_11 AC 168 ms
78,112 KB
testcase_12 AC 74 ms
70,784 KB
testcase_13 AC 73 ms
71,108 KB
testcase_14 AC 212 ms
80,636 KB
testcase_15 AC 156 ms
78,032 KB
testcase_16 AC 72 ms
70,888 KB
testcase_17 AC 77 ms
75,584 KB
testcase_18 AC 158 ms
78,560 KB
testcase_19 AC 291 ms
85,044 KB
testcase_20 AC 298 ms
86,368 KB
testcase_21 AC 206 ms
80,236 KB
testcase_22 AC 381 ms
96,024 KB
testcase_23 AC 205 ms
80,412 KB
testcase_24 AC 215 ms
80,564 KB
testcase_25 AC 107 ms
76,972 KB
testcase_26 AC 73 ms
71,008 KB
testcase_27 AC 170 ms
78,240 KB
testcase_28 AC 309 ms
87,764 KB
testcase_29 AC 399 ms
92,820 KB
testcase_30 AC 415 ms
95,788 KB
testcase_31 AC 413 ms
92,444 KB
testcase_32 AC 196 ms
79,364 KB
testcase_33 AC 194 ms
78,960 KB
testcase_34 AC 194 ms
78,956 KB
testcase_35 AC 194 ms
80,172 KB
testcase_36 AC 183 ms
79,088 KB
testcase_37 AC 187 ms
79,080 KB
testcase_38 AC 367 ms
90,268 KB
testcase_39 AC 366 ms
90,720 KB
testcase_40 AC 371 ms
90,796 KB
testcase_41 AC 194 ms
79,888 KB
testcase_42 AC 193 ms
78,708 KB
testcase_43 AC 185 ms
77,992 KB
testcase_44 AC 372 ms
91,164 KB
testcase_45 AC 388 ms
93,440 KB
testcase_46 AC 373 ms
90,936 KB
testcase_47 AC 386 ms
91,088 KB
testcase_48 AC 399 ms
91,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def MI1(): return map(int1, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
inf = 10**16
md = 998244353
# md = 10**9+7

s = II()
n = II()
tt = [II() for _ in range(n)]

def ok(m):
    dp = [(-1, -1) for _ in range(1 << n)]
    dp[0] = (m, 0)

    def chmax(i, val):
        if val > dp[i]: dp[i] = val

    for bit in range(1 << n):
        pp, pt = dp[bit]
        if pp == -1: continue
        for i in range(n):
            if bit >> i & 1: continue
            if tt[i] <= pt:
                chmax(bit | 1 << i, (pp, pt-tt[i]))
            elif pp:
                chmax(bit | 1 << i, (pp-1, s-tt[i]))

    return dp[-1]!=(-1,-1)

l, r = 0, n
while l+1 < r:
    m = (l+r)//2
    if ok(m): r = m
    else: l = m

print(r)
0