結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-02 16:58:03 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 55 ms / 5,000 ms |
| コード長 | 465 bytes |
| コンパイル時間 | 59 ms |
| コンパイル使用メモリ | 6,816 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2024-06-26 09:26:46 |
| 合計ジャッジ時間 | 1,420 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#coding: utf-8
##yuki_4
import sys
def ssum(s,k):
dp[0]=True
for i in xrange(len(s)):
for j in xrange(k,-1,-1):
if dp[j]==True and j+s[i]<=k:
dp[j+s[i]]=True
if dp[k]:
return True
return False
n=int(raw_input())
s=map(int,raw_input().split())
sum=0
for i in xrange(len(s)):
sum+=s[i]
if sum%2==1:
print "impossible"
sys.exit()
k=sum/2
dp=[False for i in xrange(n+k+1)]
res=ssum(s,k)
if res==True:
print "possible"
else:
print "impossible"