結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2021-08-26 12:08:47 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 119 ms / 5,000 ms |
コード長 | 417 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-11-18 08:53:42 |
合計ジャッジ時間 | 2,407 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
def read_int(): return int(input()) def read_int_list(): return list(map(int, input().split())) N = read_int() Ws = read_int_list() S = sum(Ws) if S & 1 != 0: print("impossible") else: dp = [False] * 10001 dp[0] = True for wi in Ws: for j in range(S // 2, -1, -1): if j + wi <= S and dp[j]: dp[j + wi] = True print("possible" if dp[S // 2] else "impossible")