結果

問題 No.370 道路の掃除
ユーザー aimyaimy
提出日時 2017-05-03 09:43:31
言語 Haskell
(9.8.2)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 453 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 162,456 KB
実行使用メモリ 11,300 KB
最終ジャッジ日時 2023-10-12 07:52:30
合計ジャッジ時間 2,220 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,160 KB
testcase_01 AC 2 ms
7,264 KB
testcase_02 AC 3 ms
7,124 KB
testcase_03 AC 2 ms
7,196 KB
testcase_04 AC 3 ms
7,084 KB
testcase_05 AC 2 ms
7,144 KB
testcase_06 AC 3 ms
7,092 KB
testcase_07 AC 3 ms
7,168 KB
testcase_08 AC 2 ms
7,108 KB
testcase_09 AC 3 ms
7,216 KB
testcase_10 AC 3 ms
7,488 KB
testcase_11 AC 3 ms
7,684 KB
testcase_12 AC 3 ms
7,652 KB
testcase_13 AC 3 ms
7,600 KB
testcase_14 AC 3 ms
7,676 KB
testcase_15 AC 3 ms
7,656 KB
testcase_16 AC 3 ms
7,660 KB
testcase_17 AC 3 ms
7,564 KB
testcase_18 AC 4 ms
7,676 KB
testcase_19 AC 3 ms
7,640 KB
testcase_20 AC 7 ms
11,272 KB
testcase_21 AC 7 ms
11,268 KB
testcase_22 AC 5 ms
10,376 KB
testcase_23 AC 6 ms
11,140 KB
testcase_24 AC 4 ms
8,300 KB
testcase_25 AC 6 ms
9,880 KB
testcase_26 AC 12 ms
11,300 KB
testcase_27 AC 5 ms
8,952 KB
testcase_28 AC 6 ms
9,780 KB
testcase_29 AC 7 ms
11,248 KB
testcase_30 AC 12 ms
11,276 KB
testcase_31 AC 6 ms
10,480 KB
testcase_32 AC 12 ms
11,272 KB
testcase_33 AC 12 ms
11,272 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List
import Data.Ord

pmap f (x,y) = (f x, f y)

main = do
 [n,_] <- map read . words <$> getLine
 ds <- map read . words <$> getContents
 print (clean n ds)

clean :: Int -> [Int] -> Int
clean n ds = minimum $ do
 let (neg,pos) = pmap (sortBy (comparing abs)) (partition (<0) ds)
 i <- [(n - length pos) .. (length neg)]
 let nx = abs (last (0:(take i neg)))
 let px = abs (last (0:(take (n-i) pos)))
 return $ 2 * (min nx px) + (max nx px)
0