結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  pasoconhoshii | 
| 提出日時 | 2019-02-09 01:32:41 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 585 bytes | 
| コンパイル時間 | 245 ms | 
| コンパイル使用メモリ | 81,844 KB | 
| 実行使用メモリ | 109,864 KB | 
| 最終ジャッジ日時 | 2024-07-01 11:51:48 | 
| 合計ジャッジ時間 | 7,050 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 5 TLE * 1 -- * 17 | 
ソースコード
#!/mnt/c/Users/moiki/bash/env/bin/python
# N,M = map(int, input().split())
N = int(input())
W = list(map(int, input().split()))
total_w = sum(W)
if total_w % 2 == 1:
    print("impossible")
    exit(0)
from copy import copy
def dfs(idx, lst):
    if sum(lst) == total_w // 2:
        return lst
    elif idx == N:
        return -1
    
    n_lst = copy(lst)
    res1 = dfs(idx+1, n_lst+[W[idx]])
    res2 = dfs(idx+1, n_lst)
    if res1 != -1 or res2 != -1:
        return 1
    else:
        return -1
if dfs(0, [])==1:
    print("possible")
else:
    print("impossible")
    
            
            
            
        