結果

問題 No.2840 RGB Plates
ユーザー suosuo
提出日時 2024-07-11 15:55:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 412 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 82,516 KB
実行使用メモリ 64,512 KB
最終ジャッジ日時 2024-07-11 16:13:32
合計ジャッジ時間 5,472 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,096 KB
testcase_01 WA -
testcase_02 AC 50 ms
59,776 KB
testcase_03 AC 40 ms
52,096 KB
testcase_04 AC 227 ms
64,512 KB
testcase_05 AC 48 ms
60,416 KB
testcase_06 AC 52 ms
61,056 KB
testcase_07 AC 51 ms
60,160 KB
testcase_08 AC 60 ms
61,568 KB
testcase_09 AC 190 ms
62,720 KB
testcase_10 WA -
testcase_11 AC 203 ms
63,360 KB
testcase_12 AC 132 ms
63,232 KB
testcase_13 AC 178 ms
63,360 KB
testcase_14 AC 166 ms
63,232 KB
testcase_15 AC 152 ms
63,232 KB
testcase_16 AC 182 ms
63,232 KB
testcase_17 AC 265 ms
63,616 KB
testcase_18 AC 257 ms
63,488 KB
testcase_19 AC 284 ms
63,232 KB
testcase_20 AC 285 ms
63,872 KB
testcase_21 AC 268 ms
62,976 KB
testcase_22 AC 75 ms
61,952 KB
testcase_23 AC 73 ms
61,696 KB
testcase_24 AC 78 ms
62,080 KB
testcase_25 AC 188 ms
63,232 KB
testcase_26 AC 156 ms
62,336 KB
testcase_27 AC 156 ms
62,464 KB
testcase_28 AC 178 ms
62,720 KB
testcase_29 AC 260 ms
64,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))

if n >= 100:
    mx = 10**4
else:
    mx = sum(a) // 2

dp = [0] * (mx + 1)
dp[0] = 1
for i in a:
    for j in range(mx - 1, -1, -1):
        if i + j > mx:
            continue
        dp[j + i] += dp[j]
        dp[j + i] = min(dp[j + i], 2)
    # print(dp)

for i in range(mx + 1):
    if dp[i] >= 2:
        print(sum(a) - 2 * i)
        exit()
print(-1)
0