結果

問題 No.4 おもりと天秤
ユーザー cleanttedcleantted
提出日時 2016-09-11 10:42:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 14,720 KB
最終ジャッジ日時 2024-04-28 10:15:10
合計ジャッジ時間 3,652 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,496 KB
testcase_01 AC 31 ms
10,496 KB
testcase_02 WA -
testcase_03 AC 33 ms
10,496 KB
testcase_04 AC 38 ms
10,624 KB
testcase_05 AC 241 ms
12,928 KB
testcase_06 WA -
testcase_07 AC 249 ms
12,800 KB
testcase_08 AC 30 ms
10,624 KB
testcase_09 WA -
testcase_10 AC 259 ms
13,184 KB
testcase_11 AC 32 ms
10,624 KB
testcase_12 AC 30 ms
10,496 KB
testcase_13 AC 30 ms
10,624 KB
testcase_14 AC 30 ms
10,496 KB
testcase_15 AC 30 ms
10,624 KB
testcase_16 AC 31 ms
10,624 KB
testcase_17 AC 30 ms
10,496 KB
testcase_18 WA -
testcase_19 AC 221 ms
12,544 KB
testcase_20 AC 217 ms
12,544 KB
testcase_21 AC 204 ms
12,416 KB
testcase_22 AC 213 ms
12,544 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)] for j in range(N+1)]
    done[N][0] = 1
    for i in range(N):
        for u in range(han):
            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] == 1: print("possible")
    else: print("impossible")
0