結果

問題 No.2542 Yokan for Two
ユーザー miya145592miya145592
提出日時 2023-11-25 02:04:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 487 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 256,892 KB
最終ジャッジ日時 2023-11-25 02:04:34
合計ジャッジ時間 10,563 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 111 ms
107,468 KB
testcase_04 AC 133 ms
106,236 KB
testcase_05 AC 337 ms
212,200 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 487 ms
256,828 KB
testcase_08 AC 166 ms
144,176 KB
testcase_09 AC 481 ms
256,892 KB
testcase_10 AC 88 ms
93,912 KB
testcase_11 AC 109 ms
97,500 KB
testcase_12 AC 293 ms
255,196 KB
testcase_13 AC 85 ms
91,188 KB
testcase_14 AC 207 ms
139,552 KB
testcase_15 AC 280 ms
173,328 KB
testcase_16 AC 244 ms
152,420 KB
testcase_17 AC 222 ms
148,048 KB
testcase_18 AC 261 ms
168,728 KB
testcase_19 AC 145 ms
107,388 KB
testcase_20 AC 122 ms
98,940 KB
testcase_21 AC 150 ms
101,372 KB
testcase_22 AC 134 ms
105,980 KB
testcase_23 AC 141 ms
104,444 KB
testcase_24 AC 39 ms
53,460 KB
testcase_25 AC 39 ms
53,460 KB
testcase_26 AC 41 ms
53,460 KB
testcase_27 AC 40 ms
53,460 KB
testcase_28 AC 46 ms
59,848 KB
testcase_29 AC 159 ms
163,212 KB
testcase_30 AC 210 ms
142,180 KB
testcase_31 AC 241 ms
143,644 KB
testcase_32 AC 207 ms
140,540 KB
testcase_33 AC 220 ms
141,112 KB
testcase_34 AC 252 ms
154,380 KB
testcase_35 AC 263 ms
164,632 KB
testcase_36 AC 256 ms
155,792 KB
testcase_37 AC 268 ms
168,320 KB
testcase_38 AC 264 ms
164,060 KB
testcase_39 AC 295 ms
184,268 KB
testcase_40 AC 284 ms
174,792 KB
testcase_41 AC 260 ms
165,060 KB
testcase_42 AC 263 ms
161,920 KB
testcase_43 AC 269 ms
168,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
L, N = map(int, input().split())
X = list(map(int, input().split()))
A = []
bk = 0
for i in range(N):
    A.append(X[i]-bk)
    bk = X[i]
A.append(L-bk)
dp = set()
dp.add(0)
for i in range(1, len(A)-1):
    ndp = set()
    for d in dp:
        ndp.add(d)
        ndp.add(d+A[i])
    dp = ndp
a = A[0]
b = A[-1]
ans = L
for d in dp:
    ans = min(ans, abs((a+d) - (b+L-(a+b)-d)))
print(ans)
0