結果

問題 No.370 道路の掃除
ユーザー ynyn
提出日時 2016-05-14 00:02:36
言語 PyPy3
(7.3.13)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 484 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 76,192 KB
最終ジャッジ日時 2023-07-28 08:13:55
合計ジャッジ時間 4,581 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,348 KB
testcase_01 AC 74 ms
71,268 KB
testcase_02 AC 76 ms
71,560 KB
testcase_03 AC 73 ms
71,124 KB
testcase_04 AC 71 ms
71,048 KB
testcase_05 AC 74 ms
71,344 KB
testcase_06 AC 75 ms
71,100 KB
testcase_07 AC 73 ms
71,356 KB
testcase_08 AC 73 ms
71,344 KB
testcase_09 AC 73 ms
71,272 KB
testcase_10 AC 74 ms
71,444 KB
testcase_11 AC 74 ms
71,296 KB
testcase_12 AC 74 ms
71,528 KB
testcase_13 AC 73 ms
71,184 KB
testcase_14 AC 73 ms
71,496 KB
testcase_15 AC 74 ms
71,088 KB
testcase_16 AC 75 ms
71,588 KB
testcase_17 AC 73 ms
71,348 KB
testcase_18 AC 74 ms
71,420 KB
testcase_19 AC 73 ms
71,540 KB
testcase_20 AC 82 ms
75,008 KB
testcase_21 AC 81 ms
75,488 KB
testcase_22 AC 79 ms
75,200 KB
testcase_23 AC 80 ms
75,164 KB
testcase_24 AC 72 ms
71,092 KB
testcase_25 AC 77 ms
71,096 KB
testcase_26 AC 83 ms
75,784 KB
testcase_27 AC 76 ms
71,104 KB
testcase_28 AC 78 ms
71,508 KB
testcase_29 AC 82 ms
75,184 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int,input().split())
d = [int(input()) for j in range(m)]
if min(d) >= 0:
    print(d[n-1])
    exit()
if max(d) <= 0:
    print(d[-n])
    exit()

start = 0
end = n - 1
ans = 100000

while end < m:
    if d[start] <= 0 and d[end] >= 0:
        ans = min(ans, d[end]-d[start]-d[start], -d[start]+d[end]+d[end])
    elif d[start] < 0 and d[end] < 0:
        ans = min(ans, abs(d[start]))
    else:
        ans = min(ans, abs(d[end]))
    start += 1
    end += 1

print(ans)
0