結果

問題 No.733 分身並列コーディング
ユーザー tobusakanatobusakana
提出日時 2022-10-23 22:59:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 173 ms / 1,500 ms
コード長 956 bytes
コンパイル時間 599 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 95,792 KB
最終ジャッジ日時 2023-09-15 07:12:56
合計ジャッジ時間 8,497 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,356 KB
testcase_01 AC 72 ms
71,220 KB
testcase_02 AC 74 ms
71,152 KB
testcase_03 AC 160 ms
95,612 KB
testcase_04 AC 150 ms
95,540 KB
testcase_05 AC 160 ms
95,792 KB
testcase_06 AC 71 ms
71,524 KB
testcase_07 AC 160 ms
95,736 KB
testcase_08 AC 168 ms
95,596 KB
testcase_09 AC 124 ms
85,396 KB
testcase_10 AC 93 ms
76,520 KB
testcase_11 AC 93 ms
76,684 KB
testcase_12 AC 72 ms
71,388 KB
testcase_13 AC 71 ms
71,356 KB
testcase_14 AC 111 ms
80,836 KB
testcase_15 AC 90 ms
76,644 KB
testcase_16 AC 73 ms
71,428 KB
testcase_17 AC 73 ms
71,432 KB
testcase_18 AC 96 ms
76,592 KB
testcase_19 AC 124 ms
85,448 KB
testcase_20 AC 125 ms
85,404 KB
testcase_21 AC 110 ms
80,788 KB
testcase_22 AC 170 ms
95,716 KB
testcase_23 AC 113 ms
80,712 KB
testcase_24 AC 112 ms
80,952 KB
testcase_25 AC 85 ms
76,608 KB
testcase_26 AC 71 ms
71,252 KB
testcase_27 AC 90 ms
76,584 KB
testcase_28 AC 168 ms
95,488 KB
testcase_29 AC 171 ms
95,580 KB
testcase_30 AC 171 ms
95,624 KB
testcase_31 AC 165 ms
95,636 KB
testcase_32 AC 96 ms
76,732 KB
testcase_33 AC 97 ms
76,636 KB
testcase_34 AC 96 ms
76,632 KB
testcase_35 AC 98 ms
76,488 KB
testcase_36 AC 96 ms
76,684 KB
testcase_37 AC 97 ms
76,732 KB
testcase_38 AC 173 ms
95,600 KB
testcase_39 AC 166 ms
95,644 KB
testcase_40 AC 170 ms
95,512 KB
testcase_41 AC 95 ms
76,624 KB
testcase_42 AC 93 ms
76,732 KB
testcase_43 AC 97 ms
76,700 KB
testcase_44 AC 168 ms
95,416 KB
testcase_45 AC 167 ms
95,584 KB
testcase_46 AC 163 ms
95,724 KB
testcase_47 AC 168 ms
95,652 KB
testcase_48 AC 165 ms
95,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

T = int(readline())
N = int(readline())
P = [int(readline()) for i in range(N)]
# dp[num][S] = 分身の数num, 解いた問題の集合Sのときに、最後の分身が残している時間

dp = [[-1] * (1 << N) for i in range(N + 1)]
dp[0][0] = 0
for status in range(1 << N):
  for num in range(N + 1):
    if dp[num][status] == -1:
      continue
    for target in range(N): # 次に解く問題
      if (status >> target) & 1:
        continue
      next_status = status | (1 << target)
      if dp[num][status] >= P[target]: # 今の分身で解ける。
        if dp[num][next_status] < dp[num][status] - P[target]:
          dp[num][next_status] = dp[num][status] - P[target]
      else: # 新たな分身が必要
        if dp[num + 1][next_status] < T - P[target]:
          dp[num + 1][next_status] = T - P[target]
        

for i in range(N + 1):
  if dp[i][-1] != -1:
    print(i)
    break
    

0