結果

問題 No.4 おもりと天秤
ユーザー Mr.FukuMr.Fuku
提出日時 2018-06-25 21:11:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 497 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 10,708 KB
実行使用メモリ 8,624 KB
最終ジャッジ日時 2023-09-13 13:55:12
合計ジャッジ時間 1,499 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,744 KB
testcase_01 AC 15 ms
7,800 KB
testcase_02 AC 15 ms
7,888 KB
testcase_03 AC 16 ms
7,872 KB
testcase_04 AC 15 ms
7,820 KB
testcase_05 AC 26 ms
8,624 KB
testcase_06 AC 16 ms
7,856 KB
testcase_07 AC 25 ms
8,492 KB
testcase_08 AC 15 ms
7,836 KB
testcase_09 AC 15 ms
7,776 KB
testcase_10 AC 26 ms
8,568 KB
testcase_11 AC 16 ms
7,756 KB
testcase_12 AC 15 ms
7,740 KB
testcase_13 AC 15 ms
7,872 KB
testcase_14 AC 15 ms
7,816 KB
testcase_15 AC 15 ms
7,820 KB
testcase_16 AC 15 ms
7,744 KB
testcase_17 AC 16 ms
7,756 KB
testcase_18 AC 36 ms
8,596 KB
testcase_19 AC 24 ms
8,572 KB
testcase_20 AC 23 ms
8,468 KB
testcase_21 AC 24 ms
8,564 KB
testcase_22 AC 23 ms
8,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!

n = int(input())
lst = list(map(int,input().split()))
kouho = []

total = sum(lst)
harf = total//2

def f():
    global kouho
    for i in lst:
        l = []
        for j in [0]+kouho:
            if j+i==harf:
                print("possible")
                return
            else:
                l.append(i+j)
        kouho += l
        kouho = list(set(kouho))
    else:
        print("impossible")

if total%2==1:
    print("impossible")
else:
    f()
0