結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  silversmith | 
| 提出日時 | 2019-05-03 19:40:52 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 517 bytes | 
| コンパイル時間 | 824 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 27,520 KB | 
| 最終ジャッジ日時 | 2024-12-31 16:08:36 | 
| 合計ジャッジ時間 | 73,177 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 13 TLE * 10 | 
ソースコード
N = int(input())
W = list(map(int,input().split()))
c_idx = 10 ** 5
dp = [False] * (2 * c_idx)
dp[c_idx + W[0]] = True
dp[c_idx - W[0]] = True
dp2 = [False] * len(dp)
for i in range(N -1):
    for x in range(2* c_idx):
        if x < W[i+1]:
            dp2[x] = dp[x + W[i+1]]
        elif x + W[i+1] > len(dp) -1:
            dp2[x] = dp[x - W[i+1]]
        else:
            dp2[x] = dp[x + W[i+1]] or dp[x - W[i+1]]
    dp, dp2 = dp2, dp
if dp[c_idx] == True:
    print('possible')
else:
    print('impossible')
            
            
            
        