結果

問題 No.370 道路の掃除
ユーザー ynyn
提出日時 2016-05-14 00:02:36
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 484 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 60,928 KB
最終ジャッジ日時 2024-04-15 17:28:08
合計ジャッジ時間 2,524 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,096 KB
testcase_01 AC 42 ms
52,908 KB
testcase_02 AC 39 ms
52,568 KB
testcase_03 AC 38 ms
51,876 KB
testcase_04 AC 37 ms
52,924 KB
testcase_05 AC 38 ms
52,284 KB
testcase_06 AC 36 ms
53,220 KB
testcase_07 AC 38 ms
52,496 KB
testcase_08 AC 38 ms
52,864 KB
testcase_09 AC 37 ms
53,608 KB
testcase_10 AC 38 ms
53,624 KB
testcase_11 AC 39 ms
52,520 KB
testcase_12 AC 39 ms
52,884 KB
testcase_13 AC 38 ms
52,556 KB
testcase_14 AC 39 ms
52,956 KB
testcase_15 AC 40 ms
52,648 KB
testcase_16 AC 38 ms
53,156 KB
testcase_17 AC 37 ms
53,112 KB
testcase_18 AC 37 ms
53,372 KB
testcase_19 AC 39 ms
53,240 KB
testcase_20 AC 46 ms
59,576 KB
testcase_21 AC 46 ms
59,776 KB
testcase_22 AC 44 ms
58,368 KB
testcase_23 AC 47 ms
59,136 KB
testcase_24 AC 39 ms
52,352 KB
testcase_25 AC 42 ms
53,760 KB
testcase_26 AC 48 ms
60,928 KB
testcase_27 AC 40 ms
53,120 KB
testcase_28 AC 41 ms
53,376 KB
testcase_29 AC 47 ms
59,136 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