結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-12 10:37:50 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 5,000 ms |
| コード長 | 563 bytes |
| コンパイル時間 | 88 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-06-26 10:10:20 |
| 合計ジャッジ時間 | 1,665 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
class Yukicoder:
def __init__(self):
self.n = int(input())
self.w_list = [int(i) for i in input().split()]
def run(self):
total = sum(self.w_list)
if total & 1: return "impossible"
half = total >> 1
dp = set([0])
for w in self.w_list:
new_dp = set(dp)
for i in dp:
t = i + w
if t == half:
return "possible"
new_dp.add(t)
dp = new_dp
return "impossible"
y = Yukicoder()
print(y.run())