結果

問題 No.4 おもりと天秤
ユーザー DialBird
提出日時 2017-03-12 09:29:11
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-25 05:16:09
合計ジャッジ時間 1,880 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 12
権限があれば一括ダウンロードができます

ソースコード

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