結果
| 問題 | No.123 カードシャッフル | 
| コンテスト | |
| ユーザー |  情報学生 | 
| 提出日時 | 2019-09-14 02:13:35 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 11 ms / 5,000 ms | 
| コード長 | 704 bytes | 
| コンパイル時間 | 6,480 ms | 
| コンパイル使用メモリ | 181,020 KB | 
| 実行使用メモリ | 11,264 KB | 
| 最終ジャッジ日時 | 2024-07-04 15:43:41 | 
| 合計ジャッジ時間 | 6,364 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 10 | 
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Control.Applicative ((<$>))
import Data.Char (isSpace)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (foldl', unfoldr)
getL :: (ByteString -> [Int]) -> IO [Int]
getL f = f <$> B.getLine
readIL :: (ByteString -> Maybe (Int, ByteString)) -> (ByteString -> [Int])
readIL f = unfoldr g
    where
        g s = do
            (n, s') <- f s
            return (n, B.dropWhile isSpace s')
main :: IO ()
main = do
    B.getLine
    as <- reverse <$> getL (readIL B.readInt)
    print $ foldl' f 1 as
    where
        f :: Int -> Int -> Int
        f acc n | acc == 1  = n
                | acc <= n  = acc - 1
                | otherwise = acc
            
            
            
        