結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2015-08-16 23:00:46 |
言語 | Python2 (2.7.18) |
結果 |
TLE
|
実行時間 | - |
コード長 | 491 bytes |
コンパイル時間 | 286 ms |
コンパイル使用メモリ | 7,040 KB |
実行使用メモリ | 14,016 KB |
最終ジャッジ日時 | 2024-07-18 09:55:22 |
合計ジャッジ時間 | 7,004 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 TLE * 1 -- * 4 |
ソースコード
def dfs(i,Sum,N,W,sumW,found): if found >= 1:return found if Sum > sumW / 2:return found if i == N and Sum == sumW / 2: found += 1 return found if i >= N:return found found += dfs(i + 1,Sum + W[i],N,W,sumW,found) found += dfs(i + 1,Sum,N,W,sumW,found) return found if __name__ == '__main__': N = int(raw_input()) W = map(int,raw_input().split()) if sum(W) % 2 == 0: if dfs(0,0,N,W,sum(W),0) >= 1: print 'possible' else: print 'impossible' else: print 'impossible'