結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,996 KB
testcase_01 AC 2 ms
6,996 KB
testcase_02 AC 3 ms
7,036 KB
testcase_03 AC 3 ms
6,996 KB
testcase_04 AC 2 ms
7,060 KB
testcase_05 AC 3 ms
7,000 KB
testcase_06 AC 2 ms
7,072 KB
testcase_07 AC 3 ms
7,028 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
7,012 KB
testcase_10 AC 12 ms
12,592 KB
testcase_11 AC 12 ms
12,696 KB
testcase_12 AC 6 ms
11,432 KB
testcase_13 AC 12 ms
12,228 KB
testcase_14 AC 12 ms
12,556 KB
testcase_15 AC 12 ms
11,700 KB
testcase_16 AC 4 ms
8,420 KB
testcase_17 AC 12 ms
12,404 KB
testcase_18 AC 12 ms
12,716 KB
testcase_19 AC 12 ms
12,776 KB
testcase_20 AC 12 ms
12,652 KB
testcase_21 AC 12 ms
12,716 KB
testcase_22 AC 12 ms
12,656 KB
testcase_23 AC 12 ms
12,792 KB
testcase_24 AC 12 ms
12,728 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