結果

問題 No.4 おもりと天秤
ユーザー DialBirdDialBird
提出日時 2017-03-12 09:29:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 8,328 KB
最終ジャッジ日時 2023-09-07 11:05:24
合計ジャッジ時間 1,829 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,248 KB
testcase_01 AC 17 ms
7,812 KB
testcase_02 AC 20 ms
8,120 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 17 ms
8,308 KB
testcase_07 WA -
testcase_08 AC 15 ms
7,960 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 18 ms
8,196 KB
testcase_12 AC 17 ms
8,264 KB
testcase_13 AC 17 ms
8,212 KB
testcase_14 AC 17 ms
8,208 KB
testcase_15 AC 17 ms
8,208 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 43 ms
8,284 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

class Yukicoder:
    def __init__(self):
        self.n = int(input())
        self.w_list = [int(i) for i in input().split()]

    def run(self):
        total = sum(self.w_list)
        if total & 1: return "impossible"

        half = total >> 1
        dp = [0]*10001
        dp[0] = 1
        for i in reversed(range(10001)):
            for w in self.w_list:
                if dp[i] == 1:
                    dp[i+w] = 1

        return "possible" if dp[half] == 1 else "impossible"

y = Yukicoder()
print(y.run())
0