結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2016-11-01 17:37:30 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 502 ms / 5,000 ms |
コード長 | 384 bytes |
コンパイル時間 | 680 ms |
コンパイル使用メモリ | 7,040 KB |
実行使用メモリ | 14,208 KB |
最終ジャッジ日時 | 2024-06-26 10:03:46 |
合計ジャッジ時間 | 6,100 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
n=int(raw_input()) w=map(int,raw_input().split()) dp=[[False]*(10**4+1) for _ in xrange(n+1)] dp[0][0] = True su=0 for i in xrange(1,n+1): su+=w[i-1] for j in xrange(10**4+1): if j-w[i-1]<0: dp[i][j] = dp[i-1][j] else: dp[i][j] = dp[i-1][j] or dp[i-1][j-w[i-1]] if su%2==1: print "impossible" else: if dp[n][su/2]: print "possible" else: print "impossible"