結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
phantomile
|
| 提出日時 | 2015-12-19 08:40:58 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 82 ms / 5,000 ms |
| コード長 | 776 bytes |
| コンパイル時間 | 310 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2024-06-26 09:21:52 |
| 合計ジャッジ時間 | 2,076 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
"""
Yukicoder No. 004 おもりと天秤
author: yamaton
date: 2015-12-18
"""
import itertools
import collections
import sys
def solve(xs, n):
total = sum(xs)
if total % 2 == 1:
return False
goal = total // 2
accum_weights = collections.defaultdict(int)
for x in xs:
for w in list(accum_weights):
accum_weights[x + w] += 1
accum_weights[x] += 1
return accum_weights[goal] > 0
def pp(*args, **kwargs):
return print(*args, file=sys.stderr, **kwargs)
def tf2msg(tf):
return 'possible' if tf else 'impossible'
def main():
n = int(input())
xs = [int(i) for i in input().split()]
assert len(xs) == n
result = tf2msg(solve(xs, n))
print(result)
if __name__ == '__main__':
main()
phantomile