結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-11-10 19:53:50 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 60 ms / 5,000 ms | 
| コード長 | 441 bytes | 
| コンパイル時間 | 438 ms | 
| コンパイル使用メモリ | 82,268 KB | 
| 実行使用メモリ | 67,840 KB | 
| 最終ジャッジ日時 | 2024-09-26 00:50:30 | 
| 合計ジャッジ時間 | 2,575 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
N = int(input())
W = list(map(int, input().split()))
goal = sum(W) // 2
if goal * 2 != sum(W):
    print("impossible")
    exit()
dp = [[False for _ in range(sum(W) + 1)] for _ in range(N + 1)]
dp[0][0] = True
for i in range(N):
    for j in range(sum(W) + 1):
        if dp[i][j] == True:
            dp[i + 1][j] = True
            dp[i + 1][j + W[i]] = True
if dp[-1][goal] == True:
    print("possible")
else:
    print("impossible")
            
            
            
        