結果
問題 | No.5 数字のブロック |
ユーザー | alpha_virginis |
提出日時 | 2016-05-04 13:08:49 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 1,229 bytes |
コンパイル時間 | 4,943 ms |
コンパイル使用メモリ | 180,944 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 08:32:56 |
合計ジャッジ時間 | 4,607 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 3 ms
6,816 KB |
testcase_03 | AC | 3 ms
6,820 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 3 ms
6,816 KB |
testcase_06 | AC | 3 ms
6,816 KB |
testcase_07 | AC | 3 ms
6,820 KB |
testcase_08 | AC | 3 ms
6,820 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | AC | 3 ms
6,820 KB |
testcase_11 | AC | 2 ms
6,816 KB |
testcase_12 | AC | 3 ms
6,816 KB |
testcase_13 | AC | 3 ms
6,816 KB |
testcase_14 | AC | 2 ms
6,820 KB |
testcase_15 | AC | 1 ms
6,816 KB |
testcase_16 | AC | 3 ms
6,816 KB |
testcase_17 | AC | 3 ms
6,816 KB |
testcase_18 | AC | 3 ms
6,820 KB |
testcase_19 | AC | 4 ms
6,820 KB |
testcase_20 | AC | 2 ms
6,820 KB |
testcase_21 | AC | 2 ms
6,816 KB |
testcase_22 | AC | 2 ms
6,820 KB |
testcase_23 | AC | 2 ms
6,820 KB |
testcase_24 | AC | 2 ms
6,824 KB |
testcase_25 | AC | 2 ms
6,824 KB |
testcase_26 | AC | 2 ms
6,820 KB |
testcase_27 | AC | 3 ms
6,820 KB |
testcase_28 | AC | 2 ms
6,820 KB |
testcase_29 | AC | 2 ms
6,816 KB |
testcase_30 | AC | 2 ms
6,816 KB |
testcase_31 | AC | 3 ms
6,816 KB |
testcase_32 | AC | 2 ms
6,816 KB |
testcase_33 | AC | 3 ms
6,816 KB |
コンパイルメッセージ
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 qualified Data.ByteString.Char8 as C import Data.Char import Data.Array.IO main :: IO () main = do s1 <- C.getLine let (l, r1) = nextInt s1 s2 <- C.getLine let (n, r2) = nextInt s2 xs <- newArray (0, 10100) 0 :: IO(IOUArray Int Int) s3 <- C.getLine set n s3 xs writeArray xs 10010 1000000 ans <- solve 0 l xs print ans set :: Int -> C.ByteString-> IOUArray Int Int -> IO () set n ss xs | n == 0 = return () | otherwise = set2 n ss xs set2 :: Int -> C.ByteString -> IOUArray Int Int -> IO () set2 n ss xs = do let (w,rs) = nextInt ss y <- readArray xs w writeArray xs w (y + 1) set (n - 1) rs xs solve :: Int -> Int -> IOUArray Int Int -> IO Int solve n l xs = do y <- readArray xs n if l >= y * n then do { t <- solve (n + 1) (l - y * n) xs; return $ t + y; } else return $ div l n nextInt :: C.ByteString -> (Int, C.ByteString) nextInt ss | isDigit x = nextInt2 0 ss | otherwise = nextInt $ C.tail ss where x = C.head ss nextInt2 :: Int -> C.ByteString -> (Int, C.ByteString) nextInt2 n ss | C.null ss = (n, ss) | isDigit y = nextInt2 (n * 10 + (digitToInt y)) ys | otherwise = (n, ys) where y = C.head ss ys = C.tail ss