結果

問題 No.370 道路の掃除
ユーザー ducktailducktail
提出日時 2018-07-04 17:06:16
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 858 bytes
コンパイル時間 10,448 ms
コンパイル使用メモリ 163,984 KB
実行使用メモリ 7,520 KB
最終ジャッジ日時 2023-09-13 17:32:02
合計ジャッジ時間 3,330 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,072 KB
testcase_01 AC 3 ms
6,952 KB
testcase_02 AC 3 ms
7,024 KB
testcase_03 AC 3 ms
7,160 KB
testcase_04 AC 3 ms
7,036 KB
testcase_05 AC 2 ms
6,972 KB
testcase_06 AC 3 ms
6,964 KB
testcase_07 AC 3 ms
7,052 KB
testcase_08 AC 3 ms
6,996 KB
testcase_09 AC 2 ms
6,968 KB
testcase_10 AC 2 ms
7,004 KB
testcase_11 AC 3 ms
7,016 KB
testcase_12 AC 2 ms
7,108 KB
testcase_13 AC 2 ms
7,060 KB
testcase_14 AC 3 ms
7,144 KB
testcase_15 AC 3 ms
7,004 KB
testcase_16 AC 3 ms
7,092 KB
testcase_17 AC 3 ms
7,200 KB
testcase_18 AC 3 ms
7,012 KB
testcase_19 AC 2 ms
7,100 KB
testcase_20 AC 3 ms
7,452 KB
testcase_21 AC 3 ms
7,420 KB
testcase_22 AC 3 ms
7,192 KB
testcase_23 AC 3 ms
7,352 KB
testcase_24 AC 2 ms
7,296 KB
testcase_25 AC 3 ms
7,308 KB
testcase_26 AC 3 ms
7,424 KB
testcase_27 AC 3 ms
7,236 KB
testcase_28 AC 2 ms
7,220 KB
testcase_29 AC 3 ms
7,304 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (unfoldr)
import Data.Char (isSpace)

main :: IO ()
main = do
  [n, m] <- readil B.readInt <$> B.getLine
  solve n <$> replicateM m (readi B.readInt <$> B.getLine) >>= print

solve :: Int -> [Int] -> Int
solve n ds = minimum . (drop (n-1) >>= zipWith f) $ ds
  where f i j | i * j >= 0 = max (abs i) (abs j)
              | otherwise = (abs i) + (abs j) + min (abs i) (abs j)

readi :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr g
  where
    g s = do
      (n, s') <- f s
      return (n, B.dropWhile isSpace s')
0