結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,488 KB
testcase_01 AC 2 ms
7,428 KB
testcase_02 AC 4 ms
9,368 KB
testcase_03 AC 3 ms
8,536 KB
testcase_04 AC 3 ms
8,204 KB
testcase_05 AC 3 ms
8,704 KB
testcase_06 AC 3 ms
8,284 KB
testcase_07 AC 3 ms
8,152 KB
testcase_08 AC 3 ms
8,404 KB
testcase_09 AC 2 ms
7,796 KB
testcase_10 AC 3 ms
8,924 KB
testcase_11 AC 3 ms
8,240 KB
testcase_12 AC 3 ms
8,484 KB
testcase_13 AC 3 ms
8,640 KB
testcase_14 AC 2 ms
7,656 KB
testcase_15 AC 2 ms
7,436 KB
testcase_16 AC 3 ms
8,800 KB
testcase_17 AC 3 ms
8,964 KB
testcase_18 AC 3 ms
8,868 KB
testcase_19 AC 4 ms
9,096 KB
testcase_20 AC 4 ms
9,336 KB
testcase_21 AC 3 ms
9,284 KB
testcase_22 AC 3 ms
9,304 KB
testcase_23 AC 2 ms
7,536 KB
testcase_24 AC 2 ms
7,516 KB
testcase_25 AC 2 ms
7,572 KB
testcase_26 AC 3 ms
9,368 KB
testcase_27 AC 4 ms
9,336 KB
testcase_28 AC 4 ms
9,368 KB
testcase_29 AC 3 ms
8,224 KB
testcase_30 AC 2 ms
7,912 KB
testcase_31 AC 4 ms
9,496 KB
testcase_32 AC 4 ms
9,468 KB
testcase_33 AC 3 ms
9,364 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