結果

問題 No.4 おもりと天秤
ユーザー momoyuumomoyuu
提出日時 2022-08-02 23:59:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 443 bytes
コンパイル時間 1,114 ms
コンパイル使用メモリ 86,440 KB
実行使用メモリ 76,008 KB
最終ジャッジ日時 2023-10-01 00:36:41
合計ジャッジ時間 3,657 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,084 KB
testcase_01 WA -
testcase_02 AC 77 ms
75,684 KB
testcase_03 AC 75 ms
75,864 KB
testcase_04 AC 76 ms
75,928 KB
testcase_05 AC 85 ms
76,008 KB
testcase_06 AC 71 ms
71,320 KB
testcase_07 AC 86 ms
75,900 KB
testcase_08 WA -
testcase_09 AC 86 ms
75,844 KB
testcase_10 AC 86 ms
75,820 KB
testcase_11 AC 79 ms
75,656 KB
testcase_12 AC 74 ms
70,768 KB
testcase_13 AC 72 ms
70,912 KB
testcase_14 AC 75 ms
75,172 KB
testcase_15 AC 71 ms
71,168 KB
testcase_16 AC 74 ms
75,568 KB
testcase_17 AC 71 ms
71,116 KB
testcase_18 AC 82 ms
75,688 KB
testcase_19 AC 82 ms
75,900 KB
testcase_20 AC 84 ms
75,748 KB
testcase_21 AC 82 ms
75,912 KB
testcase_22 AC 80 ms
75,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
W = list(map(int,input().split()))
sum = 0
for i in range(N):
    sum += W[i]
dp = [[0 for _ in range(sum+1)] for _ in range(N)]
dp[0][0] = 1
if sum % 2 == 1:
    print("impossible")

dp[0][W[0]] = 1

for i in range(1,N):
    for j in range(sum+1):
        if dp[i-1][j] == 0:
            continue
        dp[i][j] = 1
        dp[i][j+W[i]] = 1

if dp[N-1][sum//2] == 1:
    print("possible")
else:
    print("impossible")



0