結果

問題 No.733 分身並列コーディング
ユーザー tcltktcltk
提出日時 2021-09-11 05:30:20
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 834 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 86,448 KB
最終ジャッジ日時 2023-09-04 05:11:02
合計ジャッジ時間 30,646 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 221 ms
80,708 KB
testcase_01 AC 219 ms
80,816 KB
testcase_02 AC 221 ms
80,756 KB
testcase_03 AC 987 ms
85,896 KB
testcase_04 AC 999 ms
85,564 KB
testcase_05 AC 370 ms
85,692 KB
testcase_06 AC 221 ms
80,940 KB
testcase_07 AC 994 ms
86,172 KB
testcase_08 AC 923 ms
86,372 KB
testcase_09 AC 546 ms
85,384 KB
testcase_10 AC 294 ms
85,064 KB
testcase_11 AC 307 ms
85,024 KB
testcase_12 AC 226 ms
80,956 KB
testcase_13 AC 228 ms
80,916 KB
testcase_14 AC 386 ms
84,928 KB
testcase_15 AC 286 ms
84,648 KB
testcase_16 AC 226 ms
80,660 KB
testcase_17 AC 232 ms
81,412 KB
testcase_18 AC 314 ms
85,224 KB
testcase_19 AC 542 ms
84,840 KB
testcase_20 AC 554 ms
85,216 KB
testcase_21 AC 370 ms
84,712 KB
testcase_22 AC 1,018 ms
85,692 KB
testcase_23 AC 371 ms
84,732 KB
testcase_24 AC 388 ms
85,536 KB
testcase_25 AC 244 ms
84,300 KB
testcase_26 AC 219 ms
80,748 KB
testcase_27 AC 283 ms
84,780 KB
testcase_28 AC 893 ms
85,676 KB
testcase_29 AC 1,002 ms
85,748 KB
testcase_30 AC 1,052 ms
86,244 KB
testcase_31 AC 1,022 ms
85,728 KB
testcase_32 AC 321 ms
84,824 KB
testcase_33 AC 336 ms
84,776 KB
testcase_34 AC 327 ms
85,140 KB
testcase_35 AC 320 ms
85,076 KB
testcase_36 AC 321 ms
84,892 KB
testcase_37 AC 320 ms
85,096 KB
testcase_38 AC 1,031 ms
86,284 KB
testcase_39 AC 1,078 ms
86,332 KB
testcase_40 AC 1,030 ms
85,504 KB
testcase_41 AC 319 ms
85,024 KB
testcase_42 AC 338 ms
85,288 KB
testcase_43 AC 325 ms
85,000 KB
testcase_44 AC 1,037 ms
85,836 KB
testcase_45 TLE -
testcase_46 AC 1,025 ms
86,396 KB
testcase_47 AC 1,025 ms
86,096 KB
testcase_48 AC 1,036 ms
85,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """5
# 3
# 1
# 5
# 3
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10

T = int(input())
N = int(input())
A = [int(input()) for _ in range(N)]

dp = [INF] * (1<<N)
dp[0] = 0

for mask in range(1<<N):
    if sum(A[i] for i in range(N) if mask & (1<<i)) <= T:
        dp[mask] = 1

    else:
        t = bin(mask).count('1')
        mask1 = mask
        while mask1:
            # 処理を書く
            mask2 = mask ^ mask1
            t = min(t, dp[mask1] + dp[mask2])

            mask1 = (mask1-1) & mask
        
        dp[mask] = t

ans = dp[(1<<N)-1]
print(ans)
0