結果

問題 No.4 おもりと天秤
ユーザー cleanttedcleantted
提出日時 2016-09-11 11:39:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 365 ms / 5,000 ms
コード長 462 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 10,836 KB
実行使用メモリ 12,272 KB
最終ジャッジ日時 2023-09-08 17:09:43
合計ジャッジ時間 3,352 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,800 KB
testcase_01 AC 16 ms
7,804 KB
testcase_02 AC 20 ms
7,784 KB
testcase_03 AC 17 ms
7,788 KB
testcase_04 AC 21 ms
8,344 KB
testcase_05 AC 208 ms
10,472 KB
testcase_06 AC 17 ms
7,968 KB
testcase_07 AC 208 ms
10,388 KB
testcase_08 AC 15 ms
7,860 KB
testcase_09 AC 365 ms
12,272 KB
testcase_10 AC 221 ms
10,808 KB
testcase_11 AC 16 ms
7,808 KB
testcase_12 AC 16 ms
7,864 KB
testcase_13 AC 16 ms
7,760 KB
testcase_14 AC 16 ms
7,800 KB
testcase_15 AC 16 ms
7,860 KB
testcase_16 AC 16 ms
7,816 KB
testcase_17 AC 16 ms
7,872 KB
testcase_18 AC 203 ms
10,392 KB
testcase_19 AC 182 ms
10,252 KB
testcase_20 AC 189 ms
10,136 KB
testcase_21 AC 180 ms
10,040 KB
testcase_22 AC 179 ms
10,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
V = list(map(int, input().split()))

total = sum(V)
han = total // 2
if total % 2 == 1: print("impossible")
else:
    done = [[0 for i in range(han + 1)] for j in range(N+1)]
    done[N][0] = 1
    for i in range(N):
        for u in range(han + 1):
            if u < V[i] : done[i][u] = done[i-1][u]
            else: done[i][u] = max(done[i-1][u-V[i]], done[i-1][u])
    if done[N-1][han] == 1: print("possible")
    else: print("impossible")
0