結果

問題 No.4 おもりと天秤
ユーザー _manji0
提出日時 2022-01-14 01:09:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 467 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 53,920 KB
最終ジャッジ日時 2024-11-17 22:14:24
合計ジャッジ時間 1,642 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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