結果

問題 No.4 おもりと天秤
ユーザー ckawatak
提出日時 2017-07-13 13:03:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 378 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,444 KB
最終ジャッジ日時 2024-10-07 18:09:42
合計ジャッジ時間 6,780 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
values = list(map(int, input().split(' ')))

import functools
total = functools.reduce(lambda x,y: x+y, values)

def yes(i, sum, target):
    if n == i:
        return sum == target

    return yes(i+1, sum, target) or yes(i+1, sum+values[i], target)

if total%2 != 0:
    print('impossible')
else:
    print('possible' if yes(0, 0, total/2) else 'impossible')
0