結果

問題 No.4 おもりと天秤
コンテスト
ユーザー yaoshimax
提出日時 2015-02-09 07:48:06
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 336 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 294 ms
コンパイル使用メモリ 77,396 KB
最終ジャッジ日時 2025-12-03 13:36:30
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math

N = int(raw_input())
W = map(int, raw_input().split())
S=0
for w in W:
   S+=w
if S%2 != 0:
   print "impossible"
   exit()

W.sort()
L = [False for i in range(S+1)]
L[0]=True
for w in W:
   for i in range(S,-1,-1):
      if L[i] and i+w <=S:
         L[i+w]=True
if L[S/2]:
   print "possible"
else:
   print "impossible"
0