Submission #308773


Source Code Expand

import Control.Applicative
import Data.List

main = do
  str <- getContents
  let times = tail $ lines str
  let pairs = sortBy sf $ map mkpair times
  print_loop $ sortBy sf $ loop pairs []

mkpair str = (normalize (kirisage st),  normalize (kiriage ed))
  where
    [st, ed] = map read $ [take 4 str, drop 5 str]

normalize n =
  if drop 2 (show n) == "60" then n - 60 + 100
  else n

kiriage n =
  if n `mod` 5 == 0 then n
  else n + (5 - n `mod` 5)

kirisage n =
  if n `mod` 5 == 0 then n
  else n - (n `mod` 5)

myprint n =
  putStr $ replicate (4 - length s) '0' ++ s
  where s = show n

loop [] acc = acc
loop ((st, ed) : rest) acc =
  loop rest (update st ed acc)
  
update st ed acc = f r
  where r = find (\(a, b) -> st <= b) acc
        f Nothing = acc ++ [(st,ed)]
        f (Just (a,b)) = sortBy sf $ (a, max b ed) : delete (a,b) acc

print_loop [] = return ()
print_loop ((st, ed) : rest) = do
  myprint st
  putStr "-"
  myprint ed
  putStrLn ""
  print_loop rest

sf (a, _) (b, _)
  | a < b = LT
  | a > b = GT
  | otherwise = EQ

Submission Info

Submission Time
Task D - 感雨時刻の整理
User lambdataro
Language Haskell (GHC 7.4.1)
Score 0
Code Size 1097 Byte
Status WA
Exec Time 862 ms
Memory 25636 KB

Judge Result

Set Name all
Score / Max Score 0 / 100
Status
AC × 40
WA × 8
Set Name Test Cases
all 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
Case Name Status Exec Time Memory
00_sample_01.txt AC 27 ms 1164 KB
00_sample_02.txt AC 29 ms 1152 KB
00_sample_03.txt AC 27 ms 1248 KB
cho_cho_chokudai.txt AC 594 ms 16312 KB
chokudai_ga_cho.txt AC 641 ms 23568 KB
test_01.txt AC 31 ms 1676 KB
test_02.txt AC 31 ms 1672 KB
test_03.txt AC 33 ms 1692 KB
test_04.txt AC 31 ms 1620 KB
test_05.txt AC 31 ms 1680 KB
test_06.txt AC 31 ms 1804 KB
test_07.txt AC 32 ms 1756 KB
test_08.txt AC 32 ms 1736 KB
test_09.txt AC 41 ms 2104 KB
test_10.txt AC 43 ms 2188 KB
test_11.txt AC 40 ms 2056 KB
test_12.txt AC 38 ms 1912 KB
test_13.txt AC 33 ms 1796 KB
test_14.txt AC 41 ms 2132 KB
test_15.txt AC 44 ms 2184 KB
test_16.txt AC 33 ms 1772 KB
test_17.txt AC 41 ms 2056 KB
test_18.txt AC 33 ms 1768 KB
test_19.txt AC 37 ms 1984 KB
test_20.txt AC 39 ms 1968 KB
test_21.txt AC 749 ms 25508 KB
test_22.txt AC 762 ms 25508 KB
test_23.txt AC 754 ms 25516 KB
test_24.txt AC 772 ms 25508 KB
test_25.txt AC 749 ms 25508 KB
test_26.txt WA 807 ms 25512 KB
test_27.txt AC 670 ms 23504 KB
test_28.txt WA 808 ms 25512 KB
test_29.txt AC 28 ms 1176 KB
test_30.txt WA 28 ms 1676 KB
test_31.txt WA 139 ms 5128 KB
test_32.txt AC 30 ms 1652 KB
test_33.txt WA 550 ms 18344 KB
test_34.txt AC 26 ms 1184 KB
test_35.txt AC 36 ms 1856 KB
test_36.txt AC 746 ms 25620 KB
test_37.txt WA 862 ms 25516 KB
test_38.txt WA 802 ms 25636 KB
test_39.txt AC 767 ms 24612 KB
test_40.txt WA 773 ms 24560 KB
test_41.txt AC 606 ms 20520 KB
test_42.txt AC 748 ms 25524 KB
test_43.txt AC 642 ms 23484 KB