結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー こまるこまる
提出日時 2020-10-07 21:29:11
言語 Haskell
(9.8.2)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 1,120 bytes
コンパイル時間 3,357 ms
コンパイル使用メモリ 198,008 KB
実行使用メモリ 13,996 KB
最終ジャッジ日時 2023-09-27 09:59:31
合計ジャッジ時間 5,002 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
8,156 KB
testcase_01 AC 12 ms
13,996 KB
testcase_02 AC 2 ms
7,380 KB
testcase_03 AC 3 ms
7,320 KB
testcase_04 AC 2 ms
7,412 KB
testcase_05 AC 12 ms
13,880 KB
testcase_06 AC 3 ms
7,412 KB
testcase_07 AC 2 ms
7,312 KB
testcase_08 AC 2 ms
7,492 KB
testcase_09 AC 2 ms
7,360 KB
testcase_10 AC 3 ms
7,344 KB
testcase_11 AC 3 ms
7,580 KB
testcase_12 AC 2 ms
7,380 KB
testcase_13 AC 2 ms
7,364 KB
testcase_14 AC 7 ms
12,808 KB
testcase_15 AC 5 ms
11,564 KB
testcase_16 AC 12 ms
13,524 KB
testcase_17 AC 5 ms
11,168 KB
testcase_18 AC 12 ms
13,480 KB
testcase_19 AC 6 ms
12,680 KB
testcase_20 AC 12 ms
13,880 KB
testcase_21 AC 3 ms
7,728 KB
testcase_22 AC 7 ms
12,468 KB
testcase_23 AC 12 ms
13,792 KB
testcase_24 AC 12 ms
13,840 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 BangPatterns #-}
import           Control.Arrow
import qualified Data.ByteString.Char8             as BSC8
import qualified Data.Vector.Fusion.Stream.Monadic as VFSM
import qualified Data.Vector.Unboxed               as VU
import qualified Data.Vector.Unboxed.Mutable       as VUM

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

stream :: Monad m => Int -> Int -> VFSM.Stream m Int
stream !l !r = VFSM.Stream step l
  where
    step x
      | x < r     = return $ VFSM.Yield x (x + 1)
      | otherwise = return $ VFSM.Done
    {-# INLINE [0] step #-}
{-# INLINE [1] stream #-}

rep :: Monad m => Int -> (Int -> m ()) -> m ()
rep n = flip VFSM.mapM_ (stream 0 n)
{-# INLINE rep #-}

main :: IO ()
main = do
  m <- readLn :: IO Int
  l <- parseM m
  r <- VU.unsafeThaw $ VU.replicate 7 (0 :: Int)
  rep m $ \i -> do
    VUM.unsafeModify r succ (l VU.! i)
  d <- VU.unsafeFreeze r
  print . VU.last $ VU.elemIndices (VU.maximum d) d
0