結果

問題 No.4 おもりと天秤
コンテスト
ユーザー koyopro
提出日時 2015-09-20 03:56:24
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 430 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 238 ms
コンパイル使用メモリ 77,752 KB
最終ジャッジ日時 2025-12-03 17:07:47
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 TLE * 1 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# -*- 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