結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2019-07-20 10:37:21 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 56 ms / 5,000 ms |
コード長 | 599 bytes |
コンパイル時間 | 586 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-12-29 17:25:14 |
合計ジャッジ時間 | 2,571 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
def main(): """ main """ N = int(input()) WS = list(map(int, input().split())) total = sum(WS) if total & 1 == 1: print('impossible') return half = total >> 1 dp = [0 for _ in range(half+1)] dp[0] = 1 for i in WS: for j in range(half+1)[::-1]: if dp[j] == 0: continue elif i+j == half: print('possible') break elif i+j < half: dp[i+j] = 1 else: continue break else: print('impossible') main()