結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-04-27 14:57:18 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 446 bytes | 
| コンパイル時間 | 262 ms | 
| コンパイル使用メモリ | 12,416 KB | 
| 実行使用メモリ | 10,880 KB | 
| 最終ジャッジ日時 | 2024-11-21 17:39:32 | 
| 合計ジャッジ時間 | 2,475 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 WA * 3 | 
ソースコード
N = int(input())
W = list(map(int, input().split()))
full = sum(W)
if full % 2 == 1:
    print('impossible')
    exit()
dp = [-1 for i in range(full + 1)]
half = full // 2
dp[half] = 0
for i in range(N):
    for j in range(full):
        if dp[j] == i:
            if j + W[i] <= full:
                dp[j + W[i]] = i + 1
            if j - W[i] >= 0:
                dp[j - W[i]] = i + 1
print('possible' if dp[half] == N else 'impossible')
            
            
            
        