結果
| 問題 | No.365 ジェンガソート | 
| コンテスト | |
| ユーザー |  alpha_virginis | 
| 提出日時 | 2016-05-03 23:14:11 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 793 bytes | 
| コンパイル時間 | 4,011 ms | 
| コンパイル使用メモリ | 180,736 KB | 
| 実行使用メモリ | 10,880 KB | 
| 最終ジャッジ日時 | 2024-10-05 06:06:59 | 
| 合計ジャッジ時間 | 5,504 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 WA * 25 | 
コンパイルメッセージ
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
main :: IO ()
main = do
  ss <- C.getLine
  let (x,xs) = nextInt ss
  ss2 <- C.getLine
  let ans = solve 0 x ss2
  print ans
  
solve :: Int -> Int -> C.ByteString -> Int
solve i n ss
  | i == n    = 0
  | otherwise = max d $ solve (i + 1) n xs
  where d      = x - i - 1
        (x,xs) = nextInt ss
nextInt :: C.ByteString -> (Int, C.ByteString)
nextInt ss
  | '0' <= x && x <= '9' = nextInt2 ss 0
  | otherwise            = nextInt $ C.tail ss
  where x = C.head ss
nextInt2 :: C.ByteString -> Int -> (Int, C.ByteString)
nextInt2 ss n
  | C.null ss            = (n, ss)
  | '0' <= y && y <= '9' = nextInt2 ys (n * 10 + (digitToInt y))
  | otherwise            = (n, ys)
  where y  = C.head ss
        ys = C.tail ss
          
            
            
            
        