結果

問題 No.107 モンスター
ユーザー SI1000-github
提出日時 2022-10-25 14:58:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 1,083 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 82,492 KB
実行使用メモリ 77,656 KB
最終ジャッジ日時 2024-07-03 13:51:06
合計ジャッジ時間 2,770 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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