結果

問題 No.4 おもりと天秤
ユーザー DialBirdDialBird
提出日時 2017-03-12 10:12:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 62 ms / 5,000 ms
コード長 522 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 8,332 KB
最終ジャッジ日時 2023-09-08 17:19:55
合計ジャッジ時間 1,903 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,832 KB
testcase_01 AC 16 ms
7,752 KB
testcase_02 AC 21 ms
8,152 KB
testcase_03 AC 19 ms
8,176 KB
testcase_04 AC 22 ms
8,196 KB
testcase_05 AC 59 ms
8,244 KB
testcase_06 AC 16 ms
8,244 KB
testcase_07 AC 62 ms
8,224 KB
testcase_08 AC 15 ms
7,976 KB
testcase_09 AC 54 ms
8,284 KB
testcase_10 AC 61 ms
7,900 KB
testcase_11 AC 18 ms
8,188 KB
testcase_12 AC 17 ms
8,264 KB
testcase_13 AC 16 ms
8,112 KB
testcase_14 AC 17 ms
8,188 KB
testcase_15 AC 17 ms
8,192 KB
testcase_16 AC 19 ms
8,332 KB
testcase_17 AC 18 ms
8,272 KB
testcase_18 AC 57 ms
8,184 KB
testcase_19 AC 60 ms
8,212 KB
testcase_20 AC 61 ms
8,248 KB
testcase_21 AC 60 ms
8,172 KB
testcase_22 AC 61 ms
8,264 KB
権限があれば一括ダウンロードができます

ソースコード

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 w in self.w_list:
            for i in reversed(range(10001)):
                if dp[i] == 1: 
                    dp[i+w] = 1

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

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