結果

問題 No.4 おもりと天秤
ユーザー aqua_tenhouaqua_tenhou
提出日時 2021-07-11 22:24:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 386 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 75,940 KB
最終ジャッジ日時 2023-09-14 20:24:32
合計ジャッジ時間 3,398 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,840 KB
testcase_01 AC 75 ms
75,044 KB
testcase_02 AC 79 ms
75,836 KB
testcase_03 AC 77 ms
75,680 KB
testcase_04 AC 80 ms
75,936 KB
testcase_05 AC 89 ms
75,856 KB
testcase_06 AC 75 ms
75,796 KB
testcase_07 AC 90 ms
75,800 KB
testcase_08 AC 76 ms
74,908 KB
testcase_09 AC 84 ms
75,768 KB
testcase_10 AC 87 ms
75,940 KB
testcase_11 AC 76 ms
75,868 KB
testcase_12 AC 74 ms
75,776 KB
testcase_13 AC 75 ms
75,800 KB
testcase_14 AC 74 ms
75,520 KB
testcase_15 AC 74 ms
75,844 KB
testcase_16 AC 75 ms
75,728 KB
testcase_17 AC 73 ms
75,608 KB
testcase_18 AC 82 ms
75,680 KB
testcase_19 AC 85 ms
75,856 KB
testcase_20 AC 87 ms
75,680 KB
testcase_21 AC 86 ms
75,796 KB
testcase_22 AC 84 ms
75,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
w = list(map(int,input().split()))

d = [[0 for i in range(10**4 + 1)] for j in range(n+1)]
d[0][0] = 1

s = sum(w)
if s%2 == 1:
    print("impossible")
    exit()
for i in range(n):
    for j in range(10**4 + 1):
        if d[i][j] == 1:
            d[i+1][j] = 1
            d[i+1][j+w[i]] = 1

if d[-1][s//2] == 1:
    print("possible")
else:
    print("impossible")
0