結果
問題 | No.4 おもりと天秤 |
ユーザー | dango |
提出日時 | 2023-06-14 21:09:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 81 ms / 5,000 ms |
コード長 | 514 bytes |
コンパイル時間 | 1,124 ms |
コンパイル使用メモリ | 86,860 KB |
実行使用メモリ | 75,388 KB |
最終ジャッジ日時 | 2023-09-05 06:56:26 |
合計ジャッジ時間 | 3,919 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,424 KB |
testcase_01 | AC | 72 ms
71,240 KB |
testcase_02 | AC | 75 ms
75,296 KB |
testcase_03 | AC | 76 ms
75,168 KB |
testcase_04 | AC | 75 ms
75,336 KB |
testcase_05 | AC | 79 ms
75,212 KB |
testcase_06 | AC | 72 ms
71,364 KB |
testcase_07 | AC | 77 ms
75,308 KB |
testcase_08 | AC | 73 ms
71,516 KB |
testcase_09 | AC | 80 ms
75,260 KB |
testcase_10 | AC | 81 ms
75,388 KB |
testcase_11 | AC | 74 ms
71,080 KB |
testcase_12 | AC | 72 ms
71,168 KB |
testcase_13 | AC | 74 ms
71,080 KB |
testcase_14 | AC | 72 ms
71,056 KB |
testcase_15 | AC | 72 ms
71,220 KB |
testcase_16 | AC | 72 ms
71,356 KB |
testcase_17 | AC | 72 ms
71,288 KB |
testcase_18 | AC | 78 ms
75,264 KB |
testcase_19 | AC | 78 ms
75,092 KB |
testcase_20 | AC | 79 ms
75,092 KB |
testcase_21 | AC | 78 ms
75,380 KB |
testcase_22 | AC | 79 ms
75,176 KB |
ソースコード
def balance(weights: list) -> str: total_weight = sum(weights) if total_weight % 2 != 0: return "impossible" half_weight = total_weight // 2 possible = [False] * (half_weight + 1) possible[0] = True for weight in weights: for i in range(half_weight, weight - 1, -1): if possible[i - weight]: possible[i] = True return "possible" if possible[half_weight] else "impossible" N = int(input()) W = list(map(int, input().split())) print(balance(W))