結果

問題 No.4 おもりと天秤
ユーザー rocoderrocoder
提出日時 2017-08-13 17:21:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 515,708 KB
最終ジャッジ日時 2024-04-21 10:22:29
合計ジャッジ時間 6,875 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 MLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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