結果
問題 | No.4 おもりと天秤 |
ユーザー |
|
提出日時 | 2015-12-24 20:18:52 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 65 ms / 5,000 ms |
コード長 | 461 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-06-26 09:22:02 |
合計ジャッジ時間 | 1,953 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
def main(): n = input() w = list(sorted(map(int, input().split()))) s = sum(w) if s % 2 != 0: print("impossible") else: l = [0 for i in range(s // 2 + 1)] l[0] = 1 for x in w: for y in range(len(l) - 1, -1, -1): if l[y] != 0 and y + x < len(l): l[y + x] = 1 print("possible" if l[s // 2] else "impossible") if __name__ == '__main__': main()