結果

問題 No.4 おもりと天秤
ユーザー matsu7874matsu7874
提出日時 2015-08-14 17:16:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 360 ms / 5,000 ms
コード長 441 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 16,524 KB
最終ジャッジ日時 2023-09-08 16:24:16
合計ジャッジ時間 4,440 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,364 KB
testcase_01 AC 27 ms
8,656 KB
testcase_02 AC 42 ms
9,548 KB
testcase_03 AC 34 ms
9,068 KB
testcase_04 AC 44 ms
9,464 KB
testcase_05 AC 331 ms
16,524 KB
testcase_06 AC 20 ms
8,436 KB
testcase_07 AC 340 ms
16,448 KB
testcase_08 AC 183 ms
16,384 KB
testcase_09 AC 189 ms
16,440 KB
testcase_10 AC 360 ms
16,264 KB
testcase_11 AC 28 ms
8,724 KB
testcase_12 AC 21 ms
8,524 KB
testcase_13 AC 21 ms
8,444 KB
testcase_14 AC 22 ms
8,480 KB
testcase_15 AC 21 ms
8,468 KB
testcase_16 AC 29 ms
8,984 KB
testcase_17 AC 27 ms
8,792 KB
testcase_18 AC 259 ms
16,436 KB
testcase_19 AC 335 ms
16,272 KB
testcase_20 AC 320 ms
16,432 KB
testcase_21 AC 318 ms
16,492 KB
testcase_22 AC 316 ms
16,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

RANGE = 10001
ZERO = 5001
N = int(input())
W = [int(x) for x in input().split()]
dp = [[False for j in range(RANGE)] for i in range(N+1)]
dp[0][ZERO] = True
for i in range(N):
    for j in range(RANGE):
        if dp[i][j] == True:
            if j + W[i] < RANGE:
                dp[i+1][j+W[i]] = True
            if 0 <= j - W[i]:
                dp[i+1][j-W[i]] = True
if dp[N][ZERO]:
    print('possible')
else:
    print('impossible')
0