AtCoder Beginner Contest 001

Submission #109934

Source codeソースコード

import Data.List
import Data.Char
import Data.Maybe
import Data.Tuple
import Control.Applicative
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as B

debug x = trace (show x) x
(|>) x f = f x; infixl 1 |>
(||>) mx f = mx >>= (return . f); infixl 1 ||>
ref = (!!)

readInt = fst.fromJust.B.readInt
toDigit n = chr (48 + n)

parse (a:b:c:d:_:e:f:g:h:[]) =
  ( h1*100 + (div m1 5) * 5
  , if m2 > 55 then (h2+1)*100 else h2*100 + (div (m2+4) 5) * 5 )
  where
    h1 = (ord a - 48) * 10 + ord b - 48
    m1 = (ord c - 48) * 10 + ord d - 48
    h2 = (ord e - 48) * 10 + ord f - 48
    m2 = (ord g - 48) * 10 + ord h - 48

reduce :: [(Int,Int)] -> [(Int,Int)]
reduce [] = []
reduce [a] = [a]
reduce (x:y:rest) =
  if e1 < s2
    then x : (reduce $ y:rest)
    else reduce $ (s1, max e1 e2) : rest
  where (s1, e1) = x
        (s2, e2) = y

shou n
  | n < 10   = "000" ++ show n
  | n < 100  = "00" ++ show n
  | n < 1000 = "0" ++ show n
  | True = show n

main = do
  ls <- getContents ||> lines
  n  <- head ls |> readIO
  ls |> drop 1 |> take n
     |> map parse
     |> sortBy (\(a,_) (b,_) -> if a > b then GT else LT)
     |> reduce
     |> flip forM (\(s,e) -> putStrLn $ shou s ++ "-" ++ shou e)

-- vim: set ft=haskell:

Submission

Task問題 D - 感雨時刻の整理
User nameユーザ名 118_ドキドキ☆ビジュアル全開マガジン
Created time投稿日時
Language言語 Haskell (GHC 7.4.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 1306 Byte
File nameファイル名
Exec time実行時間 231 ms
Memory usageメモリ使用量 12344 KB

Test case

Set

Set name Score得点 / Max score Cases
all 100 / 100 00_sample_01.txt,00_sample_02.txt,00_sample_03.txt,cho_cho_chokudai.txt,chokudai_ga_cho.txt,test_01.txt,test_02.txt,test_03.txt,test_04.txt,test_05.txt,test_06.txt,test_07.txt,test_08.txt,test_09.txt,test_10.txt,test_11.txt,test_12.txt,test_13.txt,test_14.txt,test_15.txt,test_16.txt,test_17.txt,test_18.txt,test_19.txt,test_20.txt,test_21.txt,test_22.txt,test_23.txt,test_24.txt,test_25.txt,test_26.txt,test_27.txt,test_28.txt,test_29.txt,test_30.txt,test_31.txt,test_32.txt,test_33.txt,test_34.txt,test_35.txt,test_36.txt,test_37.txt,test_38.txt,test_39.txt,test_40.txt,test_41.txt,test_42.txt,test_43.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample_01.txt AC 33 ms 1200 KB
00_sample_02.txt AC 24 ms 1068 KB
00_sample_03.txt AC 24 ms 1308 KB
cho_cho_chokudai.txt AC 121 ms 8868 KB
chokudai_ga_cho.txt AC 121 ms 11304 KB
test_01.txt AC 28 ms 1704 KB
test_02.txt AC 24 ms 1816 KB
test_03.txt AC 27 ms 1708 KB
test_04.txt AC 24 ms 1704 KB
test_05.txt AC 25 ms 1700 KB
test_06.txt AC 25 ms 1704 KB
test_07.txt AC 27 ms 1700 KB
test_08.txt AC 26 ms 1684 KB
test_09.txt AC 25 ms 1824 KB
test_10.txt AC 30 ms 1960 KB
test_11.txt AC 27 ms 1832 KB
test_12.txt AC 26 ms 1948 KB
test_13.txt AC 26 ms 1820 KB
test_14.txt AC 29 ms 1960 KB
test_15.txt AC 28 ms 1964 KB
test_16.txt AC 26 ms 1804 KB
test_17.txt AC 32 ms 1836 KB
test_18.txt AC 25 ms 1708 KB
test_19.txt AC 26 ms 1832 KB
test_20.txt AC 27 ms 1824 KB
test_21.txt AC 178 ms 12332 KB
test_22.txt AC 178 ms 12316 KB
test_23.txt AC 180 ms 12324 KB
test_24.txt AC 175 ms 12328 KB
test_25.txt AC 207 ms 12340 KB
test_26.txt AC 231 ms 12336 KB
test_27.txt AC 149 ms 11300 KB
test_28.txt AC 201 ms 12328 KB
test_29.txt AC 26 ms 1196 KB
test_30.txt AC 25 ms 1324 KB
test_31.txt AC 41 ms 3240 KB
test_32.txt AC 25 ms 1432 KB
test_33.txt AC 142 ms 9256 KB
test_34.txt AC 25 ms 1308 KB
test_35.txt AC 24 ms 1708 KB
test_36.txt AC 176 ms 12332 KB
test_37.txt AC 191 ms 12332 KB
test_38.txt AC 174 ms 12336 KB
test_39.txt AC 181 ms 12328 KB
test_40.txt AC 186 ms 12328 KB
test_41.txt AC 104 ms 9252 KB
test_42.txt AC 184 ms 12344 KB
test_43.txt AC 115 ms 10276 KB