結果

問題 No.4 おもりと天秤
ユーザー koyopro
提出日時 2015-09-20 03:56:24
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 430 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 13,896 KB
最終ジャッジ日時 2024-07-19 08:16:26
合計ジャッジ時間 6,910 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 TLE * 1 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

n, = map(int, raw_input().split())
w = map(int, raw_input().split())

w = sorted(w)
w.reverse()

total = sum(w)
if total % 2 == 1:
    print 'impossible'
    exit()

half = total / 2
def is_pos(i, tmp):
    if tmp == half: return True
    if tmp > half: return False
    if i == len(w): return False
    return is_pos(i+1, tmp+w[i]) or is_pos(i+1, tmp)

print 'possible' if is_pos(0, 0) else 'impossible'
0