結果

問題 No.370 道路の掃除
ユーザー mlihua09mlihua09
提出日時 2020-09-15 23:05:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 332 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 75,508 KB
最終ジャッジ日時 2023-09-04 03:05:34
合計ジャッジ時間 4,972 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,356 KB
testcase_01 AC 77 ms
71,404 KB
testcase_02 AC 75 ms
71,412 KB
testcase_03 AC 78 ms
71,172 KB
testcase_04 AC 75 ms
71,324 KB
testcase_05 AC 76 ms
71,096 KB
testcase_06 AC 75 ms
71,288 KB
testcase_07 AC 75 ms
71,172 KB
testcase_08 AC 74 ms
71,324 KB
testcase_09 AC 75 ms
71,220 KB
testcase_10 AC 78 ms
71,148 KB
testcase_11 AC 79 ms
71,288 KB
testcase_12 AC 77 ms
71,208 KB
testcase_13 AC 78 ms
71,176 KB
testcase_14 AC 79 ms
71,172 KB
testcase_15 AC 79 ms
71,228 KB
testcase_16 AC 80 ms
71,216 KB
testcase_17 AC 78 ms
71,432 KB
testcase_18 AC 79 ms
71,180 KB
testcase_19 AC 78 ms
71,444 KB
testcase_20 AC 87 ms
71,412 KB
testcase_21 AC 82 ms
71,232 KB
testcase_22 AC 81 ms
71,180 KB
testcase_23 AC 84 ms
71,360 KB
testcase_24 AC 80 ms
71,292 KB
testcase_25 AC 81 ms
71,208 KB
testcase_26 AC 86 ms
75,468 KB
testcase_27 AC 79 ms
71,408 KB
testcase_28 AC 81 ms
71,432 KB
testcase_29 AC 84 ms
71,284 KB
testcase_30 AC 89 ms
75,508 KB
testcase_31 AC 84 ms
71,296 KB
testcase_32 AC 85 ms
71,172 KB
testcase_33 AC 89 ms
75,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())

Dp = [0]
Dm = [0]

for _ in range(M):
    
    d = int(input())
    
    if d >= 0:
        
        Dp += [d]
        
    else:
        
        Dm += [-d]


Dp.sort()
Dm.sort()

print(min([Dp[i] + Dm[N - i] + min(Dp[i], Dm[N - i]) for i in range(max(0, N - len(Dm) + 1), min(N + 1, len(Dp)))]))
0