結果

問題 No.4 おもりと天秤
ユーザー _manji0_manji0
提出日時 2022-01-14 01:09:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 467 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2024-04-29 00:31:37
合計ジャッジ時間 2,137 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
51,840 KB
testcase_01 AC 32 ms
51,712 KB
testcase_02 AC 33 ms
52,156 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 33 ms
51,968 KB
testcase_06 AC 33 ms
51,712 KB
testcase_07 AC 31 ms
52,480 KB
testcase_08 AC 36 ms
52,480 KB
testcase_09 AC 34 ms
51,584 KB
testcase_10 WA -
testcase_11 AC 33 ms
52,096 KB
testcase_12 AC 34 ms
51,968 KB
testcase_13 AC 33 ms
51,968 KB
testcase_14 AC 33 ms
51,712 KB
testcase_15 AC 34 ms
52,480 KB
testcase_16 WA -
testcase_17 AC 34 ms
52,096 KB
testcase_18 AC 34 ms
51,840 KB
testcase_19 AC 36 ms
52,076 KB
testcase_20 AC 36 ms
51,840 KB
testcase_21 AC 35 ms
51,840 KB
testcase_22 AC 36 ms
51,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    W = [ int(i) for i in input().split() ]

    su = sum(W)

    if su % 2 == 1:
        print("impossible")
        return

    su = su // 2

    ans1 = 0
    ans2 = 0

    W.sort()

    while W:
        w = W.pop()

        if ans1 + w <= su:
            ans1 += w
        else:
            ans2 += w

    if ans1 == ans2 == su:
        print("possible")
    else:
        print("impossible")

if __name__ == "__main__":
    main()
0