結果

問題 No.5 数字のブロック
ユーザー こまるこまる
提出日時 2020-10-17 09:35:52
言語 Haskell
(9.8.2)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,374 bytes
コンパイル時間 1,962 ms
コンパイル使用メモリ 197,996 KB
実行使用メモリ 9,504 KB
最終ジャッジ日時 2023-09-28 07:25:27
合計ジャッジ時間 4,110 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,528 KB
testcase_01 AC 3 ms
7,432 KB
testcase_02 AC 4 ms
9,396 KB
testcase_03 AC 3 ms
8,544 KB
testcase_04 AC 3 ms
8,216 KB
testcase_05 AC 4 ms
8,724 KB
testcase_06 AC 4 ms
8,344 KB
testcase_07 AC 3 ms
8,172 KB
testcase_08 AC 3 ms
8,408 KB
testcase_09 AC 3 ms
7,904 KB
testcase_10 AC 4 ms
8,932 KB
testcase_11 AC 3 ms
8,220 KB
testcase_12 AC 4 ms
8,600 KB
testcase_13 AC 4 ms
8,688 KB
testcase_14 AC 3 ms
7,732 KB
testcase_15 AC 3 ms
7,480 KB
testcase_16 AC 4 ms
8,828 KB
testcase_17 AC 4 ms
9,092 KB
testcase_18 AC 4 ms
8,952 KB
testcase_19 AC 4 ms
9,064 KB
testcase_20 AC 4 ms
9,504 KB
testcase_21 AC 4 ms
9,404 KB
testcase_22 AC 4 ms
9,396 KB
testcase_23 AC 2 ms
7,424 KB
testcase_24 AC 2 ms
7,472 KB
testcase_25 AC 3 ms
7,656 KB
testcase_26 AC 4 ms
9,460 KB
testcase_27 AC 4 ms
9,388 KB
testcase_28 AC 4 ms
9,396 KB
testcase_29 AC 3 ms
8,280 KB
testcase_30 AC 3 ms
7,864 KB
testcase_31 AC 4 ms
9,396 KB
testcase_32 AC 4 ms
9,448 KB
testcase_33 AC 4 ms
9,460 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 #

{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE TupleSections      #-}

import           Control.Arrow
import qualified Data.ByteString.Char8             as BSC8
import qualified Data.Vector.Unboxed               as VU

-------------------------------------------------------------------------------
-- input
-------------------------------------------------------------------------------
type Parser a = BSC8.ByteString -> Maybe (a, BSC8.ByteString)
parseInt :: Parser Int
parseInt = fmap (second BSC8.tail) . BSC8.readInt
parseM :: Int -> IO (VU.Vector Int)
parseM m = VU.unfoldrN m parseInt <$> BSC8.getLine

-------------------------------------------------------------------------------
-- Bucket Sort
-------------------------------------------------------------------------------
bucketSortVU :: Int -> VU.Vector Int -> VU.Vector Int
bucketSortVU bucketSize
  = VU.concatMap (uncurry $ flip VU.replicate)
  . VU.indexed
  . VU.unsafeAccumulate (+) (VU.replicate bucketSize 0)
  . VU.map (, 1)
{-# INLINE bucketSortVU #-}

-------------------------------------------------------------------------------
-- main
-------------------------------------------------------------------------------
main :: IO ()
main = do
  l  <- readLn :: IO Int
  m  <- readLn :: IO Int
  ws <- parseM m
  print . VU.length . VU.takeWhile (<= l) . VU.scanl1' (+) . bucketSortVU 10_000 $ ws
0