結果

問題 No.107 モンスター
ユーザー roiti46roiti46
提出日時 2015-02-23 22:03:09
言語 Python2
(2.7.18)
結果
AC  
実行時間 754 ms / 5,000 ms
コード長 476 bytes
コンパイル時間 965 ms
コンパイル使用メモリ 6,636 KB
実行使用メモリ 6,516 KB
最終ジャッジ日時 2023-08-22 22:43:43
合計ジャッジ時間 6,682 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,908 KB
testcase_01 AC 12 ms
5,904 KB
testcase_02 AC 11 ms
5,876 KB
testcase_03 AC 11 ms
5,904 KB
testcase_04 AC 12 ms
5,908 KB
testcase_05 AC 11 ms
5,944 KB
testcase_06 AC 11 ms
5,920 KB
testcase_07 AC 12 ms
5,872 KB
testcase_08 AC 12 ms
5,904 KB
testcase_09 AC 11 ms
5,908 KB
testcase_10 AC 12 ms
5,948 KB
testcase_11 AC 12 ms
5,960 KB
testcase_12 AC 12 ms
6,000 KB
testcase_13 AC 174 ms
6,068 KB
testcase_14 AC 398 ms
6,196 KB
testcase_15 AC 398 ms
6,196 KB
testcase_16 AC 12 ms
5,988 KB
testcase_17 AC 83 ms
6,068 KB
testcase_18 AC 634 ms
6,280 KB
testcase_19 AC 597 ms
6,172 KB
testcase_20 AC 203 ms
6,052 KB
testcase_21 AC 184 ms
5,984 KB
testcase_22 AC 365 ms
5,900 KB
testcase_23 AC 754 ms
6,516 KB
testcase_24 AC 648 ms
6,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(raw_input())
D = map(int,raw_input().split())
bad = 0
for i in xrange(N):
    if D[i] < 0: bad |= 1 << i
    
dp = [0]*(1 << N)
dp[0] = 100
for bit in xrange(1 << N):
    for i in xrange(N):
        beat = bin(bad & bit).count("1")
        if dp[bit] == 0 or bit & (1 << i): continue
        if D[i] < 0: dp[bit | 1 << i] = max(dp[bit | 1 << i], dp[bit]+D[i])
        else: dp[bit | 1 << i] = max(dp[bit | 1 << i], min(100*(beat+1), dp[bit]+D[i]))
print dp[(1 << N)-1]
0