結果

問題 No.370 道路の掃除
ユーザー yuppe19 😺yuppe19 😺
提出日時 2017-06-18 14:42:02
言語 Python2
(2.7.18)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 19:45:50
合計ジャッジ時間 1,571 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
# (ΦωΦ)<左からi個、右からN-i個取ることにする。
#
n, m = map(int, raw_input().split())
a = [int(raw_input()) for _ in xrange(m)]
lh = sorted([abs(x) for x in a if x < 0])
rh = sorted([x for x in a if x >= 0])
M = len(lh)
N = len(rh)

mini = float('inf')
if 0 <= n-1 < N: # i==0
    mini = min(mini, rh[n-1])
if 0 <= n-1 < M: # i==n
    mini = min(mini, lh[n-1])

for i in xrange(1, n):
    if 0 <= i-1 < M and 0 <= n-i-1 < N:
        mini = min(mini, lh[i-1] * 2 + rh[n-i-1], lh[i-1] + rh[n-i-1] * 2)
print mini
0