結果

問題 No.2542 Yokan for Two
ユーザー PNJPNJ
提出日時 2023-11-24 23:26:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 569 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 62,660 KB
最終ジャッジ日時 2023-11-24 23:26:09
合計ジャッジ時間 5,006 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 59 ms
62,660 KB
testcase_04 AC 57 ms
62,052 KB
testcase_05 AC 72 ms
62,544 KB
testcase_06 AC 44 ms
59,924 KB
testcase_07 AC 92 ms
62,584 KB
testcase_08 AC 58 ms
62,488 KB
testcase_09 AC 90 ms
62,580 KB
testcase_10 AC 52 ms
62,052 KB
testcase_11 AC 55 ms
62,040 KB
testcase_12 AC 66 ms
62,524 KB
testcase_13 AC 51 ms
62,016 KB
testcase_14 AC 83 ms
62,584 KB
testcase_15 AC 89 ms
62,624 KB
testcase_16 AC 86 ms
62,604 KB
testcase_17 AC 82 ms
62,576 KB
testcase_18 AC 87 ms
62,640 KB
testcase_19 AC 67 ms
62,280 KB
testcase_20 AC 67 ms
62,248 KB
testcase_21 AC 65 ms
62,248 KB
testcase_22 AC 66 ms
62,260 KB
testcase_23 AC 67 ms
62,264 KB
testcase_24 AC 45 ms
60,424 KB
testcase_25 AC 50 ms
62,648 KB
testcase_26 AC 49 ms
62,644 KB
testcase_27 AC 50 ms
62,644 KB
testcase_28 AC 50 ms
62,644 KB
testcase_29 AC 61 ms
62,644 KB
testcase_30 AC 85 ms
62,644 KB
testcase_31 AC 85 ms
62,644 KB
testcase_32 AC 85 ms
62,644 KB
testcase_33 AC 86 ms
62,644 KB
testcase_34 AC 87 ms
62,644 KB
testcase_35 AC 88 ms
62,644 KB
testcase_36 AC 87 ms
62,644 KB
testcase_37 AC 87 ms
62,644 KB
testcase_38 AC 87 ms
62,644 KB
testcase_39 AC 90 ms
62,644 KB
testcase_40 AC 89 ms
62,648 KB
testcase_41 AC 86 ms
62,648 KB
testcase_42 AC 87 ms
62,648 KB
testcase_43 AC 87 ms
62,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().strip()

def Map():
  return list(map(int,input().split()))

L,N = Map()
X = Map()
W = []
for i in range(N-1):
  d = X[i+1] - X[i]
  W.append(d)

dp = [0 for i in range(L+1)]
dp[0] = 1
for w in W:
  for l in range(L,-1,-1):
    if dp[l]:
      ll = l + w
      if ll <= L:
        dp[ll] = 1

ans = L
for l in range(L):
  if dp[l]:
    a = l + X[0]
    b = L - a
    ans = min(ans,abs(a-b))
print(ans)
0