結果

問題 No.4 おもりと天秤
ユーザー かいかい
提出日時 2023-06-19 03:36:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 5,000 ms
コード長 429 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 76,868 KB
最終ジャッジ日時 2023-09-08 21:40:28
合計ジャッジ時間 3,622 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,744 KB
testcase_01 AC 81 ms
75,944 KB
testcase_02 AC 87 ms
76,232 KB
testcase_03 AC 82 ms
76,088 KB
testcase_04 AC 80 ms
76,180 KB
testcase_05 AC 97 ms
76,772 KB
testcase_06 AC 76 ms
75,684 KB
testcase_07 AC 100 ms
76,868 KB
testcase_08 AC 82 ms
76,236 KB
testcase_09 AC 85 ms
76,196 KB
testcase_10 AC 104 ms
76,688 KB
testcase_11 AC 82 ms
75,824 KB
testcase_12 AC 82 ms
75,656 KB
testcase_13 AC 78 ms
75,824 KB
testcase_14 AC 78 ms
75,884 KB
testcase_15 AC 77 ms
75,904 KB
testcase_16 AC 78 ms
75,852 KB
testcase_17 AC 77 ms
75,928 KB
testcase_18 AC 90 ms
76,676 KB
testcase_19 AC 97 ms
76,644 KB
testcase_20 AC 97 ms
76,832 KB
testcase_21 AC 98 ms
76,800 KB
testcase_22 AC 101 ms
76,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
W = list(map(int, input().split()))

dp = [False for _ in range(100*100+1)]
dp[0] = True
# print(dp[2])
for i in range(N):
    s = set()
    for j in range(10001):
        if dp[j] and j+W[i]<=10000:
            s.add(j+W[i])
    for k in s:
        dp[k] = True
# for i in range(10001):
#     if dp[i]:
#         print(i-1)
if sum(W)%2 == 0 and dp[sum(W)//2]:
    print("possible")
else:
    print("impossible")
0