結果

問題 No.4 おもりと天秤
ユーザー syunsukesyunsuke
提出日時 2019-04-21 08:30:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,127 ms / 5,000 ms
コード長 389 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-15 06:14:05
合計ジャッジ時間 9,114 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 26 ms
10,752 KB
testcase_02 AC 35 ms
10,880 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 38 ms
10,880 KB
testcase_05 AC 932 ms
10,752 KB
testcase_06 AC 27 ms
10,880 KB
testcase_07 AC 911 ms
10,880 KB
testcase_08 AC 26 ms
10,752 KB
testcase_09 AC 1,127 ms
10,752 KB
testcase_10 AC 1,011 ms
10,752 KB
testcase_11 AC 28 ms
10,880 KB
testcase_12 AC 26 ms
10,880 KB
testcase_13 AC 26 ms
10,880 KB
testcase_14 AC 27 ms
10,752 KB
testcase_15 AC 26 ms
10,880 KB
testcase_16 AC 27 ms
10,752 KB
testcase_17 AC 26 ms
10,752 KB
testcase_18 AC 751 ms
10,752 KB
testcase_19 AC 837 ms
10,752 KB
testcase_20 AC 833 ms
10,880 KB
testcase_21 AC 782 ms
10,880 KB
testcase_22 AC 803 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())

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

if sum(W)%2==1:
    print("impossible")
else:
    
    dp=[0 for i in range(sum(W)+1)]
    
    dp[0]=1
    for i in range(len(W)):
        for j in range(len(dp)):
            if dp[sum(W)-1-j]==1:
                dp[sum(W)-1-j+W[i]]=1
    
    if dp[sum(W)//2]==0:
        print("impossible")
    else:
        print("possible")
        
0