結果

問題 No.4 おもりと天秤
ユーザー szkhtsszkhts
提出日時 2020-07-12 10:15:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 298 ms / 5,000 ms
コード長 526 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-04-22 11:17:19
合計ジャッジ時間 4,691 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
19,072 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 102 ms
19,072 KB
testcase_03 AC 95 ms
19,072 KB
testcase_04 AC 104 ms
19,072 KB
testcase_05 AC 298 ms
19,072 KB
testcase_06 AC 85 ms
19,200 KB
testcase_07 AC 283 ms
19,072 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 217 ms
19,072 KB
testcase_10 AC 288 ms
19,072 KB
testcase_11 AC 94 ms
19,200 KB
testcase_12 AC 86 ms
19,200 KB
testcase_13 AC 87 ms
19,072 KB
testcase_14 AC 89 ms
19,200 KB
testcase_15 AC 87 ms
19,072 KB
testcase_16 AC 92 ms
19,072 KB
testcase_17 AC 92 ms
19,200 KB
testcase_18 AC 249 ms
19,072 KB
testcase_19 AC 281 ms
19,072 KB
testcase_20 AC 271 ms
19,072 KB
testcase_21 AC 273 ms
19,072 KB
testcase_22 AC 268 ms
19,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

num = int(input())

numbers = list(map(int, input().split()))

summery = 0
for number in numbers:
    summery += number

if summery % 2 == 0:
    dp = [[0 for i in range(10001)] for j in range(101)]
    dp[0][0] = 1
    for i in range(num):
        for j in range(10001):
            if dp[i][j] == 1:
                dp[i + 1][j + numbers[i]] = 1
                dp[i + 1][j] = 1
                
    if dp[num][summery // 2] == 1:
        print("possible")
    else:
        print("impossible")
else:
    print("impossible")
0