結果

問題 No.2542 Yokan for Two
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-11-24 21:56:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 65,408 KB
最終ジャッジ日時 2023-11-24 21:56:42
合計ジャッジ時間 5,660 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,332 KB
testcase_01 AC 34 ms
53,332 KB
testcase_02 AC 35 ms
53,332 KB
testcase_03 AC 65 ms
63,324 KB
testcase_04 AC 62 ms
62,116 KB
testcase_05 AC 88 ms
63,076 KB
testcase_06 AC 44 ms
60,344 KB
testcase_07 AC 123 ms
63,192 KB
testcase_08 AC 67 ms
63,012 KB
testcase_09 AC 122 ms
63,176 KB
testcase_10 AC 54 ms
62,116 KB
testcase_11 AC 56 ms
62,096 KB
testcase_12 AC 79 ms
63,048 KB
testcase_13 AC 54 ms
62,048 KB
testcase_14 AC 102 ms
63,196 KB
testcase_15 AC 109 ms
63,268 KB
testcase_16 AC 105 ms
63,228 KB
testcase_17 AC 102 ms
63,172 KB
testcase_18 AC 111 ms
63,300 KB
testcase_19 AC 77 ms
62,580 KB
testcase_20 AC 73 ms
62,512 KB
testcase_21 AC 79 ms
62,512 KB
testcase_22 AC 74 ms
62,536 KB
testcase_23 AC 77 ms
62,548 KB
testcase_24 AC 45 ms
61,088 KB
testcase_25 AC 50 ms
63,320 KB
testcase_26 AC 50 ms
63,316 KB
testcase_27 AC 52 ms
63,324 KB
testcase_28 AC 51 ms
63,316 KB
testcase_29 AC 67 ms
65,404 KB
testcase_30 AC 102 ms
63,312 KB
testcase_31 AC 103 ms
63,312 KB
testcase_32 AC 103 ms
63,312 KB
testcase_33 AC 105 ms
63,312 KB
testcase_34 AC 111 ms
63,312 KB
testcase_35 AC 109 ms
63,312 KB
testcase_36 AC 106 ms
63,312 KB
testcase_37 AC 108 ms
63,312 KB
testcase_38 AC 107 ms
63,312 KB
testcase_39 AC 112 ms
65,404 KB
testcase_40 AC 111 ms
65,408 KB
testcase_41 AC 108 ms
63,308 KB
testcase_42 AC 107 ms
63,308 KB
testcase_43 AC 107 ms
63,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

l,n = map(int,input().split())
X = list(map(int,input().split())) + [l]
dp = [[0]*(l+1) for i in range(2)]
dp[0][X[0]] = 1

for bx,x in zip(X,X[1:]):
    dif = x-bx

    for i in range(l)[::-1]:

        if dp[0][i]:
            dp[0][i+dif] = 1
            dp[1][i] = 1
        
        if dp[1][i]:
            dp[0][i+dif] = 1

ans = l
for i in range(l+1):
    if dp[1][i]:
        ans = min(ans,abs(i - (l-i)))
print(ans)
0