結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  antyanpome | 
| 提出日時 | 2020-06-26 15:34:27 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 560 bytes | 
| コンパイル時間 | 142 ms | 
| コンパイル使用メモリ | 82,360 KB | 
| 実行使用メモリ | 72,960 KB | 
| 最終ジャッジ日時 | 2024-07-04 01:02:15 | 
| 合計ジャッジ時間 | 2,369 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 2 RE * 21 | 
ソースコード
n = int(input())
w_list = list(map(int,input().split()))
all_weight = sum(w_list)
if all_weight%2==1:
    print("impossible")
else:
    target = all_weight//2
    dp = [[False for i in range(target)] for i in range(n+1)]
    for i in range(n):
        for j in range(target):
            if (j >= w_list[i] and dp[i][j - w_list[i]] == True) or dp[i][j] == True:
                dp[i+1][j] = True
            else:
                dp[i+1][j] = False
                
    if dp[-1][target] == True:
        print("possible")
    else:
        print("impossible")
            
            
            
        