結果

問題 No.4 おもりと天秤
ユーザー tanon710
提出日時 2019-04-14 03:52:59
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 356 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 29,940 KB
最終ジャッジ日時 2024-09-15 11:32:17
合計ジャッジ時間 2,644 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
arr=list(map(int,input().split()))
add=sum(arr)
div=int(add/2)
flag=(add)%2
dp=[{} for _ in range(n)]
dp[0][arr[0]]=1
for i in range(1,n):
    for j in dp[i-1].keys():
        dp[i][j]=1
        dp[i][j+arr[i]]=1
if flag==1:
    print('impossible')
else:
    if div in dp[n-1]:
        print('possible')
    else:
        print('impossible')
0