結果

問題 No.370 道路の掃除
ユーザー norimisonorimiso
提出日時 2018-02-08 02:03:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 593 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 10,208 KB
最終ジャッジ日時 2023-10-21 13:55:29
合計ジャッジ時間 2,249 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

# coding: utf-8
# Your code here!
gomi, num = map(int, input().split())
plus = [1000000]
minus = [-1000000]
for i in range(num):
    a = int(input())
    if a >= 0:
        plus.append(a)
    else:
        minus.append(a)
plus.sort()
minus.sort()
minus.reverse()
current = 0
count = 0
ans = 0
while(1):
    if abs(current - plus[0]) <= abs(current - minus[0]):
        ans += abs(current - plus[0])
        current = plus.pop(0)
        count += 1
    else:
        ans += abs(current - minus[0])
        current = minus.pop(0)
        count += 1
    if count >= gomi:
        break
print(ans)
0