結果

問題 No.4 おもりと天秤
ユーザー tanon710tanon710
提出日時 2019-04-14 03:52:59
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 356 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 10,700 KB
実行使用メモリ 27,408 KB
最終ジャッジ日時 2023-10-13 14:47:03
合計ジャッジ時間 2,164 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,784 KB
testcase_01 AC 15 ms
7,816 KB
testcase_02 AC 16 ms
8,176 KB
testcase_03 AC 14 ms
7,772 KB
testcase_04 AC 15 ms
8,332 KB
testcase_05 AC 109 ms
24,312 KB
testcase_06 AC 14 ms
7,708 KB
testcase_07 AC 118 ms
25,108 KB
testcase_08 AC 16 ms
8,268 KB
testcase_09 AC 16 ms
8,428 KB
testcase_10 AC 127 ms
27,408 KB
testcase_11 AC 15 ms
7,800 KB
testcase_12 AC 15 ms
7,876 KB
testcase_13 AC 16 ms
7,892 KB
testcase_14 AC 15 ms
7,872 KB
testcase_15 AC 14 ms
7,844 KB
testcase_16 AC 15 ms
7,740 KB
testcase_17 AC 14 ms
7,852 KB
testcase_18 AC 62 ms
16,348 KB
testcase_19 AC 91 ms
23,444 KB
testcase_20 AC 93 ms
23,224 KB
testcase_21 AC 91 ms
22,380 KB
testcase_22 AC 97 ms
23,572 KB
権限があれば一括ダウンロードができます

ソースコード

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