結果

問題 No.286 Modulo Discount Store
ユーザー tcltktcltk
提出日時 2021-05-17 15:38:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,185 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 33,564 KB
最終ジャッジ日時 2024-04-16 04:06:06
合計ジャッジ時間 8,342 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
16,896 KB
testcase_01 AC 44 ms
11,392 KB
testcase_02 AC 837 ms
15,616 KB
testcase_03 AC 35 ms
11,520 KB
testcase_04 AC 38 ms
11,392 KB
testcase_05 AC 34 ms
11,392 KB
testcase_06 AC 1,886 ms
20,352 KB
testcase_07 AC 33 ms
11,392 KB
testcase_08 AC 34 ms
11,520 KB
testcase_09 AC 34 ms
11,264 KB
testcase_10 AC 368 ms
13,312 KB
testcase_11 AC 35 ms
11,520 KB
testcase_12 AC 35 ms
11,520 KB
testcase_13 AC 825 ms
15,360 KB
testcase_14 AC 34 ms
11,392 KB
testcase_15 AC 34 ms
11,520 KB
testcase_16 AC 43 ms
11,520 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/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)
#endregion

# _INPUT = """3
# 100
# 200
# 300
# """
# sys.stdin = io.StringIO(_INPUT)


def main():
    N = int(input())
    M = [int(input()) for _ in range(N)]

    dp = [[0] * (1<<N) for _ in range(N+1)]
    for i in range(N):
        for s in range(1<<N):


            regular_price = 0
            n = 0
            for j in range(N):
                if s & (1<<j) > 0:
                    n += 0
                    regular_price += M[j]
            if n > i:
                continue
            discount = regular_price % 1000

            for k in range(N):
                # 商品k が購入されていないなら、購入する
                if s & (1<<k) == 0:
                    s1 = s | (1<<k)
                    dp[i+1][s1] = max(dp[i+1][s1], dp[i][s] + min(discount, M[k]))

    max_discount = dp[N][(1<<N)-1]
    price = sum(M) - max_discount
    print(price)


if __name__ == '__main__':
    main()
0