結果

問題 No.2542 Yokan for Two
ユーザー rlangevinrlangevin
提出日時 2023-11-24 21:35:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 303 ms / 2,000 ms
コード長 592 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 221,656 KB
最終ジャッジ日時 2023-11-24 21:35:51
合計ジャッジ時間 9,214 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 120 ms
112,700 KB
testcase_04 AC 87 ms
93,712 KB
testcase_05 AC 185 ms
140,240 KB
testcase_06 AC 51 ms
66,560 KB
testcase_07 AC 215 ms
201,656 KB
testcase_08 AC 117 ms
101,764 KB
testcase_09 AC 302 ms
197,264 KB
testcase_10 AC 70 ms
80,420 KB
testcase_11 AC 107 ms
84,684 KB
testcase_12 AC 131 ms
123,196 KB
testcase_13 AC 74 ms
77,736 KB
testcase_14 AC 232 ms
211,144 KB
testcase_15 AC 242 ms
218,424 KB
testcase_16 AC 240 ms
214,384 KB
testcase_17 AC 303 ms
208,724 KB
testcase_18 AC 269 ms
221,656 KB
testcase_19 AC 159 ms
148,932 KB
testcase_20 AC 149 ms
141,772 KB
testcase_21 AC 146 ms
142,012 KB
testcase_22 AC 153 ms
144,488 KB
testcase_23 AC 150 ms
145,696 KB
testcase_24 AC 62 ms
72,972 KB
testcase_25 AC 68 ms
79,276 KB
testcase_26 AC 74 ms
79,244 KB
testcase_27 AC 74 ms
82,912 KB
testcase_28 AC 74 ms
84,468 KB
testcase_29 AC 106 ms
106,944 KB
testcase_30 AC 237 ms
220,892 KB
testcase_31 AC 253 ms
220,892 KB
testcase_32 AC 236 ms
220,892 KB
testcase_33 AC 236 ms
220,892 KB
testcase_34 AC 237 ms
220,888 KB
testcase_35 AC 244 ms
220,892 KB
testcase_36 AC 244 ms
220,896 KB
testcase_37 AC 236 ms
220,888 KB
testcase_38 AC 237 ms
220,888 KB
testcase_39 AC 239 ms
220,896 KB
testcase_40 AC 239 ms
220,900 KB
testcase_41 AC 249 ms
220,896 KB
testcase_42 AC 243 ms
220,896 KB
testcase_43 AC 236 ms
220,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

L, N = map(int, input().split())
X = list(map(int, input().split()))
pre0 = [0] * (L + 1)
pre1 = [0] * (L + 1)
pre1[X[0]] = 1
XX = []
X.append(L)
for i in range(N):
    XX.append(X[i + 1] - X[i])
for x in XX:
    dp0 = [0] * (L + 1)
    dp1 = [0] * (L + 1)
    for i in range(L + 1):
        if i - x >= 0:
            dp1[i] |= pre1[i - x]
            dp1[i] |= pre0[i - x]
        dp0[i] |= pre1[i]
        dp0[i] |= pre0[i]
    pre0, dp0 = dp0, pre0
    pre1, dp1 = dp1, pre1

ans = 10 ** 18
for i in range(L + 1):
    if pre0[i]:
        ans = min(ans, abs(2 * i - L))
        
print(ans)
0