結果

問題 No.286 Modulo Discount Store
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-10-12 04:58:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 973 ms
コンパイル使用メモリ 86,204 KB
実行使用メモリ 79,384 KB
最終ジャッジ日時 2023-09-08 05:27:51
合計ジャッジ時間 7,723 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
72,196 KB
testcase_01 AC 120 ms
77,224 KB
testcase_02 AC 132 ms
77,440 KB
testcase_03 AC 107 ms
72,388 KB
testcase_04 AC 109 ms
72,388 KB
testcase_05 AC 113 ms
72,228 KB
testcase_06 AC 139 ms
77,388 KB
testcase_07 AC 112 ms
72,364 KB
testcase_08 AC 110 ms
72,260 KB
testcase_09 AC 111 ms
72,260 KB
testcase_10 AC 132 ms
77,360 KB
testcase_11 AC 112 ms
72,292 KB
testcase_12 AC 109 ms
72,288 KB
testcase_13 AC 136 ms
77,412 KB
testcase_14 AC 109 ms
72,304 KB
testcase_15 AC 107 ms
72,228 KB
testcase_16 AC 121 ms
77,224 KB
testcase_17 AC 155 ms
79,384 KB
testcase_18 AC 130 ms
77,448 KB
testcase_19 AC 108 ms
72,300 KB
testcase_20 AC 130 ms
77,612 KB
testcase_21 AC 110 ms
72,432 KB
testcase_22 AC 109 ms
72,472 KB
testcase_23 AC 137 ms
77,488 KB
testcase_24 AC 110 ms
72,320 KB
testcase_25 AC 134 ms
77,468 KB
testcase_26 AC 108 ms
72,608 KB
testcase_27 AC 134 ms
77,468 KB
testcase_28 AC 139 ms
77,548 KB
testcase_29 AC 107 ms
72,164 KB
testcase_30 AC 108 ms
72,492 KB
testcase_31 AC 128 ms
77,308 KB
testcase_32 AC 123 ms
77,496 KB
testcase_33 AC 108 ms
72,328 KB
testcase_34 AC 109 ms
72,392 KB
testcase_35 AC 119 ms
77,156 KB
testcase_36 AC 107 ms
72,216 KB
testcase_37 AC 131 ms
77,376 KB
testcase_38 AC 110 ms
72,264 KB
testcase_39 AC 137 ms
77,284 KB
testcase_40 AC 106 ms
72,256 KB
testcase_41 AC 107 ms
72,436 KB
testcase_42 AC 107 ms
72,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N = int(input())
M = [int(input()) for _ in range(N)]
mod = 1000

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

for i in range(1<<N):
    
    for j in range(N):
        if (i>>j)&1:
            S[i] += M[j]

dp[0]=0
for i in range(1<<N):
    
    target = []
    for j in range(N):
        if (i>>j)&1:
            continue
        target.append(j)
        
    for t in target:
        
        dp[i|(1<<t)] = min(dp[i|(1<<t)],dp[i] + max(0,M[t] - S[i]%1000))
print(dp[-1])
0