結果
問題 | No.4 おもりと天秤 |
ユーザー |
|
提出日時 | 2017-05-10 20:31:23 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 487 bytes |
コンパイル時間 | 449 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-15 07:11:19 |
合計ジャッジ時間 | 2,089 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 WA * 3 |
ソースコード
def solve(n, w_list): total = sum(w_list) if total % 2 != 0: return "impossible" k = total // 2 dp = [False] * (k + 1) dp[0] = True for w in w_list: for i in range(len(dp)): if dp[i] and i + w < len(dp): dp[i + w] = True return "possible" if dp[k] else "impossible" def main(): n = int(input()) w_list = list(map(int, input().split())) print(solve(n, w_list)) if __name__ == '__main__': main()