結果

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

ソースコード

diff #

# your code goes here
n = input()
b = list(int(i) for i in input().split())
b.reverse()
#print(b)
N=sum(b)
e=1
#print(N)
def sca(e,r,i,ba):
    if e==0:
        return 0
    elif r-ba[i]==0:
        e=0
        return 0
    elif r-ba[i] < 0:
            return 1*sca(e,r,i+1,ba)
    elif len(ba)==1:
        return 1
    else:
        ba=ba.pop(i)
        return 1*sca(e,r-b[i],i,ba)
if N/2!=int(N/2):
    print("impossible")
else:
    N=int(N/2)
#print(N)
if sca(e,N,0,b)==0:
    print("possible")
else:
    print("impossible")
0