結果

問題 No.4 おもりと天秤
ユーザー rocoder
提出日時 2017-08-13 16:49:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 484 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-13 09:08:54
合計ジャッジ時間 1,818 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#scale
N=int(input())
W=[int(i) for i in input().split()]
S=0
for i in range(N):
    S+=W[i]
if S%2==1:
    p="impossible"
else:
    W.sort()
    S//=2
    S-=W[-1]
    W.pop(-1)
    T=[0]
    U=[0]
    for i in range(N):
        T=U
        j=0
        while Nd==0 and j <N:
            v=T[j]+W[i]
            if v==S:
                Nd=1
            else:
                U.append(v)
            set(U)
            j+=1
if Nd==1:
    p="possible"
else:
    p="impossible"
print(p)
0