結果

問題 No.286 Modulo Discount Store
ユーザー SI1000-githubSI1000-github
提出日時 2022-10-25 14:42:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 86,752 KB
実行使用メモリ 80,964 KB
最終ジャッジ日時 2023-09-16 13:10:58
合計ジャッジ時間 5,386 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,184 KB
testcase_01 AC 81 ms
76,640 KB
testcase_02 AC 95 ms
76,804 KB
testcase_03 AC 72 ms
71,220 KB
testcase_04 AC 74 ms
71,336 KB
testcase_05 AC 72 ms
71,336 KB
testcase_06 AC 108 ms
77,132 KB
testcase_07 AC 73 ms
71,428 KB
testcase_08 AC 71 ms
71,296 KB
testcase_09 AC 73 ms
71,364 KB
testcase_10 AC 95 ms
76,788 KB
testcase_11 AC 73 ms
71,308 KB
testcase_12 AC 72 ms
71,076 KB
testcase_13 AC 97 ms
76,448 KB
testcase_14 AC 73 ms
71,336 KB
testcase_15 AC 71 ms
71,332 KB
testcase_16 AC 80 ms
76,452 KB
testcase_17 AC 132 ms
80,964 KB
testcase_18 AC 95 ms
76,720 KB
testcase_19 AC 71 ms
71,336 KB
testcase_20 AC 90 ms
76,852 KB
testcase_21 AC 72 ms
71,424 KB
testcase_22 AC 72 ms
71,276 KB
testcase_23 AC 102 ms
77,276 KB
testcase_24 AC 71 ms
71,332 KB
testcase_25 AC 102 ms
77,404 KB
testcase_26 AC 71 ms
70,940 KB
testcase_27 AC 98 ms
76,456 KB
testcase_28 AC 108 ms
77,260 KB
testcase_29 AC 71 ms
71,428 KB
testcase_30 AC 72 ms
71,280 KB
testcase_31 AC 86 ms
76,328 KB
testcase_32 AC 82 ms
76,744 KB
testcase_33 AC 72 ms
71,276 KB
testcase_34 AC 70 ms
71,296 KB
testcase_35 AC 80 ms
76,408 KB
testcase_36 AC 70 ms
71,360 KB
testcase_37 AC 95 ms
76,688 KB
testcase_38 AC 71 ms
71,468 KB
testcase_39 AC 111 ms
79,212 KB
testcase_40 AC 69 ms
71,284 KB
testcase_41 AC 70 ms
70,936 KB
testcase_42 AC 69 ms
71,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
# -*- coding: utf-8 -*-

# import
from sys import stdin, setrecursionlimit
setrecursionlimit(10**8)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def int_mtx(N):
    x = [list(map(int, stdin.readline().split())) for _ in range(N)]
    return x

def str_mtx(N):
    x = [list(stdin.readline()[:-1]) for _ in range(N)]
    return x

def print_space(l):
    return print(" ".join([str(x) for x in l]))



"""    main code    """

N = int(input())
M = []
for _ in range(N):
    Mi = int(input())
    M.append(Mi)

dp = [[float("INF"),0] for _ in range(2**N)]
dp[0][0] = 0

for s in range(2**N):
    for u in range(N):
        if s >> u & 1 == 0:
            dp[s+2**u][0] = min(dp[s+2**u][0],dp[s][0]+max(0,M[u]-dp[s][1]))
            dp[s+2**u][1] = (dp[s][1]+M[u])%1000

print(dp[2**N-1][0])


0