結果

問題 No.107 モンスター
ユーザー SI1000-githubSI1000-github
提出日時 2022-10-25 14:58:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 157 ms / 5,000 ms
コード長 1,083 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 78,436 KB
最終ジャッジ日時 2023-09-16 13:22:07
合計ジャッジ時間 4,340 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,080 KB
testcase_01 AC 70 ms
71,384 KB
testcase_02 AC 71 ms
71,208 KB
testcase_03 AC 71 ms
71,132 KB
testcase_04 AC 75 ms
71,184 KB
testcase_05 AC 71 ms
71,032 KB
testcase_06 AC 72 ms
71,288 KB
testcase_07 AC 71 ms
71,092 KB
testcase_08 AC 69 ms
71,256 KB
testcase_09 AC 73 ms
71,220 KB
testcase_10 AC 72 ms
71,248 KB
testcase_11 AC 71 ms
71,056 KB
testcase_12 AC 72 ms
71,184 KB
testcase_13 AC 123 ms
77,392 KB
testcase_14 AC 119 ms
77,564 KB
testcase_15 AC 119 ms
77,648 KB
testcase_16 AC 73 ms
71,112 KB
testcase_17 AC 117 ms
77,524 KB
testcase_18 AC 147 ms
78,436 KB
testcase_19 AC 143 ms
78,312 KB
testcase_20 AC 110 ms
77,304 KB
testcase_21 AC 118 ms
77,336 KB
testcase_22 AC 136 ms
77,960 KB
testcase_23 AC 144 ms
78,412 KB
testcase_24 AC 157 ms
78,236 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())
D = int_list()

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

for s in range(2**N):
    level = 1
    for u in range(N):
        if s >> u & 1 == 1 and D[u] < 0:
            level += 1
    
    for u in range(N):
        if s >> u & 1 == 0:
            if D[u] < 0:
                if dp[s]+D[u] > 0:
                    dp[s+2**u] = max(dp[s+2**u], min(level*100, dp[s]+D[u]))
            else:
                dp[s+2**u] = max(dp[s+2**u], min(level*100, dp[s]+D[u]))

if dp[2**N-1] == -float("INF"):
    print(0)
else:
    print(dp[2**N-1])


0