結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,624 KB
testcase_01 AC 27 ms
10,624 KB
testcase_02 WA -
testcase_03 AC 28 ms
10,624 KB
testcase_04 AC 33 ms
10,752 KB
testcase_05 AC 226 ms
12,928 KB
testcase_06 AC 26 ms
10,496 KB
testcase_07 AC 226 ms
12,928 KB
testcase_08 AC 26 ms
10,624 KB
testcase_09 WA -
testcase_10 AC 252 ms
13,184 KB
testcase_11 AC 26 ms
10,624 KB
testcase_12 AC 24 ms
10,624 KB
testcase_13 AC 24 ms
10,496 KB
testcase_14 AC 25 ms
10,752 KB
testcase_15 AC 25 ms
10,624 KB
testcase_16 AC 25 ms
10,624 KB
testcase_17 AC 24 ms
10,624 KB
testcase_18 WA -
testcase_19 AC 201 ms
12,800 KB
testcase_20 AC 202 ms
12,672 KB
testcase_21 AC 189 ms
12,672 KB
testcase_22 AC 197 ms
12,672 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] - 1: done[i][u] = done[i-1][u]
            else: done[i][u] = max(done[i-1][u-V[i]+1], done[i-1][u])
    if done[N-1][han-1] == 1: print("possible")
    else: print("impossible")
0