結果

問題 No.370 道路の掃除
ユーザー TatsunoTatsuno
提出日時 2016-05-13 22:47:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 926 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 16,512 KB
最終ジャッジ日時 2024-04-15 16:42:24
合計ジャッジ時間 3,761 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
16,384 KB
testcase_01 AC 36 ms
11,008 KB
testcase_02 AC 36 ms
11,008 KB
testcase_03 AC 35 ms
11,136 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
d=[0]*20001
for i in range(m):
    d[int(input())+10000] += 1
left=0
right=0
acc = 0
for i in range(len(d)):
    acc += d[i]
    right = i
    if acc >= n:
        break

def dist(l, r):
    if r <= 10000:
        return 10000 - l
    if l >= 10000:
        return r - 10000
    return r-l + min(10000 - l, r - 10000)

ans = dist(left, right)
while right < 20000:
    if acc >= n:
        acc -= d[left]
        for i in range(left+1, 20001):
            if d[i] > 0:
                left = i
                break
        if left >= right:
            acc = d[left]
            right = left
        if acc >= n:
            ans = min(ans, dist(left, right))
            continue

    for i in range(right+1, 20001):
        if d[i] > 0:
            right = i
            break
    else:
        break
    acc += d[right]
    if acc >= n:
        ans = min(ans, dist(left, right))
    
print(ans)
0