結果

問題 No.2542 Yokan for Two
ユーザー komkompikomkompi
提出日時 2023-11-25 13:44:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 255 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 141,964 KB
最終ジャッジ日時 2023-11-25 13:44:35
合計ジャッジ時間 8,924 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 111 ms
87,492 KB
testcase_04 AC 88 ms
78,596 KB
testcase_05 AC 145 ms
101,376 KB
testcase_06 AC 46 ms
62,700 KB
testcase_07 AC 221 ms
132,028 KB
testcase_08 AC 95 ms
82,184 KB
testcase_09 AC 213 ms
131,924 KB
testcase_10 AC 71 ms
71,944 KB
testcase_11 AC 76 ms
74,092 KB
testcase_12 AC 124 ms
93,920 KB
testcase_13 AC 66 ms
70,640 KB
testcase_14 AC 227 ms
136,772 KB
testcase_15 AC 236 ms
140,364 KB
testcase_16 AC 231 ms
138,376 KB
testcase_17 AC 225 ms
135,564 KB
testcase_18 AC 243 ms
141,964 KB
testcase_19 AC 153 ms
105,976 KB
testcase_20 AC 145 ms
102,420 KB
testcase_21 AC 144 ms
102,548 KB
testcase_22 AC 146 ms
103,776 KB
testcase_23 AC 149 ms
104,376 KB
testcase_24 AC 57 ms
66,576 KB
testcase_25 AC 66 ms
69,712 KB
testcase_26 AC 68 ms
71,808 KB
testcase_27 AC 70 ms
72,588 KB
testcase_28 AC 72 ms
73,372 KB
testcase_29 AC 100 ms
85,656 KB
testcase_30 AC 238 ms
141,588 KB
testcase_31 AC 239 ms
141,592 KB
testcase_32 AC 241 ms
141,580 KB
testcase_33 AC 241 ms
141,580 KB
testcase_34 AC 241 ms
141,580 KB
testcase_35 AC 241 ms
141,588 KB
testcase_36 AC 255 ms
141,588 KB
testcase_37 AC 241 ms
141,580 KB
testcase_38 AC 240 ms
141,592 KB
testcase_39 AC 240 ms
141,592 KB
testcase_40 AC 242 ms
141,580 KB
testcase_41 AC 240 ms
141,592 KB
testcase_42 AC 242 ms
141,592 KB
testcase_43 AC 239 ms
141,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!

L,N=map(int,input().split())
X=list(map(int,input().split()))

X=[0]+X+[L]

diff=[X[i+1]-X[i] for i in range(N+1)]

A=diff[0]
B=diff[-1]
diff=diff[1:-1]

dp=[[0 for i in range(L+1)] for j in range(N)]
dp[0][0]=1


for n in range(N-1):
    for l in range(L+1):
        dp[n+1][l]|=dp[n][l]
        if l+diff[n]<=L:
            dp[n+1][l+diff[n]]|=dp[n][l]

sum_diff=sum(diff)
ans=10**18
for l in range(L+1):
    if dp[-1][l]:
        ans=min(ans,abs(A+l-B-(sum_diff-l)))


print(ans)

0