結果

問題 No.921 ずんだアロー
ユーザー こまるこまる
提出日時 2020-11-14 13:46:03
言語 Haskell
(9.8.2)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 1,049 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 169,808 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2023-09-30 04:55:59
合計ジャッジ時間 2,379 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,048 KB
testcase_01 AC 3 ms
7,052 KB
testcase_02 AC 3 ms
7,072 KB
testcase_03 AC 2 ms
6,996 KB
testcase_04 AC 3 ms
7,000 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
7,076 KB
testcase_07 AC 2 ms
7,172 KB
testcase_08 AC 2 ms
7,000 KB
testcase_09 AC 3 ms
7,100 KB
testcase_10 AC 12 ms
12,636 KB
testcase_11 AC 12 ms
12,664 KB
testcase_12 AC 7 ms
11,360 KB
testcase_13 AC 12 ms
12,172 KB
testcase_14 AC 12 ms
12,460 KB
testcase_15 AC 12 ms
11,712 KB
testcase_16 AC 4 ms
8,356 KB
testcase_17 AC 12 ms
12,364 KB
testcase_18 AC 12 ms
12,656 KB
testcase_19 AC 12 ms
12,772 KB
testcase_20 AC 22 ms
12,728 KB
testcase_21 AC 12 ms
12,792 KB
testcase_22 AC 12 ms
12,800 KB
testcase_23 AC 12 ms
12,736 KB
testcase_24 AC 12 ms
12,732 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 #

import           Control.Monad               (forM_)
import qualified Data.ByteString.Char8       as BSC8
import           Data.Maybe                  (fromJust)
import qualified Data.Vector.Unboxed.Mutable as VUM

main :: IO ()
main = do
  getLine
  ax <- getIntList
  dp <- VUM.replicate 3 (0 :: Int)
  forM_ ax $ \a -> do
    p   <- VUM.unsafeRead dp 1
    f   <- VUM.unsafeRead dp 2
    if a == p
      then VUM.unsafeModify dp succ 0 >> VUM.unsafeWrite dp 2 1
      else if f /= 0
        then VUM.unsafeWrite dp 1 0 >> VUM.unsafeWrite dp 2 0
        else VUM.unsafeModify dp succ 0 >> VUM.unsafeWrite dp 2 1
    VUM.unsafeWrite dp 1 a
  print =<< VUM.unsafeRead dp 0

--input
readInt :: BSC8.ByteString -> Int
readInt = fst . fromJust . BSC8.readInt
{-# INLINE readInt #-}
getInt :: IO Int
getInt = readInt <$> BSC8.getLine
{-# INLINE getInt #-}
readIntList :: BSC8.ByteString -> [Int]
readIntList = map readInt . BSC8.words
{-# INLINE readIntList #-}
getIntList :: IO [Int]
getIntList = readIntList <$> BSC8.getLine
{-# INLINE getIntList #-}
0