結果

問題 No.4 おもりと天秤
ユーザー antyanpomeantyanpome
提出日時 2020-06-26 15:38:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 76,252 KB
最終ジャッジ日時 2023-09-17 03:22:14
合計ジャッジ時間 3,541 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
71,368 KB
testcase_01 AC 59 ms
71,252 KB
testcase_02 WA -
testcase_03 AC 63 ms
75,952 KB
testcase_04 AC 67 ms
76,212 KB
testcase_05 AC 76 ms
76,120 KB
testcase_06 WA -
testcase_07 AC 77 ms
76,192 KB
testcase_08 AC 58 ms
71,112 KB
testcase_09 WA -
testcase_10 AC 75 ms
76,124 KB
testcase_11 AC 63 ms
76,164 KB
testcase_12 AC 58 ms
71,272 KB
testcase_13 AC 61 ms
71,484 KB
testcase_14 AC 62 ms
71,616 KB
testcase_15 AC 59 ms
71,268 KB
testcase_16 AC 63 ms
76,164 KB
testcase_17 AC 61 ms
71,300 KB
testcase_18 WA -
testcase_19 AC 76 ms
76,196 KB
testcase_20 AC 76 ms
76,048 KB
testcase_21 AC 74 ms
76,252 KB
testcase_22 AC 75 ms
76,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
w_list = list(map(int,input().split()))
all_weight = sum(w_list)
if all_weight%2==1:
    print("impossible")
else:
    target = all_weight//2
    dp = [[False for i in range(target)] for i in range(n+1)]
    dp[0][0] = True
    for i in range(n):
        for j in range(target):
            if (j >= w_list[i] and dp[i][j - w_list[i]] == True) or dp[i][j] == True:
                dp[i+1][j] = True
            else:
                dp[i+1][j] = False
                
    if dp[-1][-1] == True:
        print("possible")
    else:
        print("impossible")
        
0