結果

問題 No.4 おもりと天秤
ユーザー koyoprokoyopro
提出日時 2015-09-20 03:56:24
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 430 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 6,608 KB
実行使用メモリ 11,852 KB
最終ジャッジ日時 2023-09-26 13:58:29
合計ジャッジ時間 7,382 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
11,852 KB
testcase_01 AC 11 ms
5,856 KB
testcase_02 AC 19 ms
5,932 KB
testcase_03 AC 11 ms
5,976 KB
testcase_04 AC 11 ms
5,844 KB
testcase_05 AC 11 ms
5,876 KB
testcase_06 AC 12 ms
5,980 KB
testcase_07 AC 11 ms
5,984 KB
testcase_08 AC 11 ms
5,952 KB
testcase_09 AC 12 ms
5,868 KB
testcase_10 AC 12 ms
5,976 KB
testcase_11 AC 11 ms
5,836 KB
testcase_12 AC 11 ms
5,952 KB
testcase_13 AC 12 ms
5,956 KB
testcase_14 AC 11 ms
5,836 KB
testcase_15 AC 11 ms
5,964 KB
testcase_16 AC 11 ms
5,944 KB
testcase_17 AC 11 ms
5,928 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

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