結果

問題 No.370 道路の掃除
コンテスト
ユーザー ima-yoshi
提出日時 2016-05-13 22:43:40
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 514 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,343 ms
コンパイル使用メモリ 189,440 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2026-04-21 03:23:29
合計ジャッジ時間 8,994 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31 RE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #
raw source code

import Control.Monad.ST
import Control.Monad
import Data.Array.ST
import Data.Array
import Data.STRef
import Control.Monad
import Control.Applicative
import Data.List
getMin a b
  | a<0 && b<0 = negate a
  | a>0 && b>0 = b
  | otherwise = (b-a) + min (negate a) b
ans n (a:as) c
  | c < n = 800000000
  | otherwise = min (getMin a ((a:as) !! (n-1))) (ans n as (c-1))
main = do
  [n,m] <- map read <$> words <$> getLine ::IO [Int]
  b <- sort <$> map read <$> words <$> getContents ::IO [Int]
  print $ ans n b m


0