結果

問題 No.370 道路の掃除
ユーザー roarisroaris
提出日時 2019-12-16 14:30:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 320 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 75,468 KB
最終ジャッジ日時 2023-09-15 17:36:19
合計ジャッジ時間 4,034 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,128 KB
testcase_01 AC 69 ms
71,284 KB
testcase_02 AC 71 ms
71,264 KB
testcase_03 AC 69 ms
71,328 KB
testcase_04 AC 69 ms
70,984 KB
testcase_05 AC 69 ms
71,524 KB
testcase_06 AC 70 ms
71,264 KB
testcase_07 AC 67 ms
71,156 KB
testcase_08 AC 68 ms
71,456 KB
testcase_09 AC 68 ms
71,388 KB
testcase_10 AC 68 ms
71,164 KB
testcase_11 AC 69 ms
71,216 KB
testcase_12 AC 69 ms
71,096 KB
testcase_13 AC 69 ms
71,372 KB
testcase_14 AC 70 ms
71,452 KB
testcase_15 AC 68 ms
71,368 KB
testcase_16 AC 69 ms
71,128 KB
testcase_17 AC 69 ms
71,200 KB
testcase_18 AC 70 ms
71,280 KB
testcase_19 AC 68 ms
70,984 KB
testcase_20 AC 75 ms
71,128 KB
testcase_21 AC 77 ms
70,988 KB
testcase_22 AC 73 ms
71,152 KB
testcase_23 AC 76 ms
71,136 KB
testcase_24 AC 72 ms
71,160 KB
testcase_25 AC 73 ms
71,132 KB
testcase_26 AC 78 ms
75,180 KB
testcase_27 AC 72 ms
71,424 KB
testcase_28 AC 73 ms
71,176 KB
testcase_29 AC 75 ms
71,360 KB
testcase_30 AC 80 ms
75,396 KB
testcase_31 AC 75 ms
71,224 KB
testcase_32 AC 77 ms
71,392 KB
testcase_33 AC 82 ms
75,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
D = [int(input()) for _ in range(M)]
D.sort()
ans = 10**18

for i in range(M-N+1):
    j = i+N-1
    
    if D[i]<0 and D[j]<0:
        ans = min(ans, -D[i])
    elif D[i]<0 and D[j]>=0:
        ans = min(ans, -2*D[i]+D[j], 2*D[j]-D[i])
    else:
        ans = min(ans, D[j])

print(ans)
0