結果

問題 No.4 おもりと天秤
ユーザー goto_isyukugoto_isyuku
提出日時 2017-05-29 20:21:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 255 ms / 5,000 ms
コード長 488 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 16,588 KB
最終ジャッジ日時 2023-09-08 17:30:00
合計ジャッジ時間 3,434 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,916 KB
testcase_01 AC 16 ms
7,820 KB
testcase_02 AC 19 ms
8,288 KB
testcase_03 AC 17 ms
8,356 KB
testcase_04 AC 21 ms
8,436 KB
testcase_05 AC 233 ms
16,444 KB
testcase_06 AC 15 ms
7,856 KB
testcase_07 AC 255 ms
16,504 KB
testcase_08 AC 16 ms
7,900 KB
testcase_09 AC 177 ms
16,432 KB
testcase_10 AC 251 ms
16,560 KB
testcase_11 AC 16 ms
7,804 KB
testcase_12 AC 15 ms
7,848 KB
testcase_13 AC 15 ms
7,816 KB
testcase_14 AC 15 ms
7,892 KB
testcase_15 AC 16 ms
7,916 KB
testcase_16 AC 16 ms
8,276 KB
testcase_17 AC 16 ms
7,864 KB
testcase_18 AC 212 ms
16,512 KB
testcase_19 AC 243 ms
16,436 KB
testcase_20 AC 241 ms
16,508 KB
testcase_21 AC 222 ms
16,496 KB
testcase_22 AC 243 ms
16,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
wl = [int(x) for x in input().split()]

if sum(wl) % 2 == 1:
    print("impossible")
else:

    dp = [[0 for x in range(n * 100 + 1)] for y in range(n + 1)]
    
    for i in range(n + 1):
        dp[i][0] = 1
    
    for i in range(n):
        for j in range(n * 100):
            if dp[i][j] == 1:
                dp[i + 1][j] = 1
                dp[i + 1][j + wl[i]] = 1
    if dp[n][sum(wl) // 2] == 1:
        print("possible")
    else:
        print("impossible")
0