結果

問題 No.4 おもりと天秤
ユーザー zinnnia123zinnnia123
提出日時 2019-08-18 13:33:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-08 23:54:21
合計ジャッジ時間 1,636 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 29 ms
10,624 KB
testcase_07 WA -
testcase_08 AC 30 ms
10,624 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 29 ms
10,752 KB
testcase_12 AC 30 ms
10,752 KB
testcase_13 AC 30 ms
10,624 KB
testcase_14 AC 30 ms
10,752 KB
testcase_15 AC 31 ms
10,752 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 30 ms
10,752 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

A = sum(W)

S = [[0]*(A+1)]*(N+1)
S[0][0] = 1

if (A/2).is_integer() == False:
    print('impossible')
    exit()
else:
    A = int(A/2)
    for i in range(N+1):
        for j in range(A+1):
            if S[i][j] == 1:
                if j + W[i] > A:
                    print('impossible')
                    exit()
                else:
                    S[i+1][j+W[i]] = 1
                    S[i+1][j] = 1
    if S[N][A] == 1:
        print('possible')
    else:
        print('impossible')            
0