結果

問題 No.4 おもりと天秤
ユーザー szkhtsszkhts
提出日時 2020-07-12 10:15:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 246 ms / 5,000 ms
コード長 526 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 16,556 KB
最終ジャッジ日時 2023-08-04 13:39:47
合計ジャッジ時間 4,066 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
16,380 KB
testcase_01 AC 16 ms
7,876 KB
testcase_02 AC 74 ms
16,400 KB
testcase_03 AC 68 ms
16,448 KB
testcase_04 AC 76 ms
16,352 KB
testcase_05 AC 225 ms
16,500 KB
testcase_06 AC 58 ms
16,344 KB
testcase_07 AC 240 ms
16,388 KB
testcase_08 AC 15 ms
7,748 KB
testcase_09 AC 175 ms
16,448 KB
testcase_10 AC 244 ms
16,456 KB
testcase_11 AC 66 ms
16,344 KB
testcase_12 AC 58 ms
16,380 KB
testcase_13 AC 60 ms
16,492 KB
testcase_14 AC 62 ms
16,436 KB
testcase_15 AC 62 ms
16,460 KB
testcase_16 AC 67 ms
16,372 KB
testcase_17 AC 66 ms
16,384 KB
testcase_18 AC 210 ms
16,312 KB
testcase_19 AC 246 ms
16,380 KB
testcase_20 AC 214 ms
16,424 KB
testcase_21 AC 226 ms
16,556 KB
testcase_22 AC 230 ms
16,500 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