結果

問題 No.2542 Yokan for Two
ユーザー 👑 rin204rin204
提出日時 2023-11-24 23:26:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 62,784 KB
最終ジャッジ日時 2023-11-24 23:26:16
合計ジャッジ時間 6,775 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 77 ms
62,784 KB
testcase_04 AC 70 ms
62,180 KB
testcase_05 AC 104 ms
62,672 KB
testcase_06 AC 44 ms
60,064 KB
testcase_07 AC 149 ms
62,716 KB
testcase_08 AC 74 ms
62,624 KB
testcase_09 AC 145 ms
62,708 KB
testcase_10 AC 61 ms
62,180 KB
testcase_11 AC 64 ms
62,168 KB
testcase_12 AC 90 ms
62,652 KB
testcase_13 AC 59 ms
62,156 KB
testcase_14 AC 140 ms
62,720 KB
testcase_15 AC 148 ms
62,756 KB
testcase_16 AC 150 ms
62,736 KB
testcase_17 AC 137 ms
62,708 KB
testcase_18 AC 148 ms
62,772 KB
testcase_19 AC 106 ms
62,412 KB
testcase_20 AC 95 ms
62,380 KB
testcase_21 AC 100 ms
62,380 KB
testcase_22 AC 98 ms
62,392 KB
testcase_23 AC 102 ms
62,396 KB
testcase_24 AC 49 ms
60,432 KB
testcase_25 AC 56 ms
62,784 KB
testcase_26 AC 56 ms
62,784 KB
testcase_27 AC 58 ms
62,780 KB
testcase_28 AC 58 ms
62,776 KB
testcase_29 AC 78 ms
62,780 KB
testcase_30 AC 146 ms
62,776 KB
testcase_31 AC 153 ms
62,776 KB
testcase_32 AC 158 ms
62,776 KB
testcase_33 AC 146 ms
62,776 KB
testcase_34 AC 147 ms
62,776 KB
testcase_35 AC 148 ms
62,776 KB
testcase_36 AC 147 ms
62,776 KB
testcase_37 AC 149 ms
62,776 KB
testcase_38 AC 149 ms
62,776 KB
testcase_39 AC 153 ms
62,776 KB
testcase_40 AC 150 ms
62,776 KB
testcase_41 AC 157 ms
62,776 KB
testcase_42 AC 156 ms
62,776 KB
testcase_43 AC 149 ms
62,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

l, n = map(int, input().split())
X = list(map(int, input().split()))
A = []
for i in range(n - 1):
    A.append(X[i + 1] - X[i])
tf = [False] * (l + 1)
tf[0] = True
for a in A:
    for i in range(l, a - 1, -1):
        tf[i] |= tf[i - a]

aa = X[0]
bb = l - X[-1]
ans = l
for i in range(l):
    if tf[i]:
        a_ = aa + i
        b_ = l - a_
        ans = min(ans, abs(a_ - b_))
print(ans)
0