Submission #308778


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 (mytostr 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)

mytostr n =
  replicate (4 - length s) '0' ++ s
  where s = show n
  
myprint n = putStr $ mytostr 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 $ (min a st, 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 100
Code Size 1134 Byte
Status AC
Exec Time 884 ms
Memory 25980 KB

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 48
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 40 ms 1420 KB
00_sample_02.txt AC 28 ms 1360 KB
00_sample_03.txt AC 31 ms 1432 KB
cho_cho_chokudai.txt AC 645 ms 18572 KB
chokudai_ga_cho.txt AC 664 ms 23724 KB
test_01.txt AC 35 ms 1908 KB
test_02.txt AC 34 ms 1936 KB
test_03.txt AC 34 ms 1936 KB
test_04.txt AC 34 ms 1936 KB
test_05.txt AC 35 ms 1908 KB
test_06.txt AC 36 ms 1932 KB
test_07.txt AC 35 ms 1936 KB
test_08.txt AC 34 ms 1912 KB
test_09.txt AC 43 ms 2320 KB
test_10.txt AC 45 ms 2320 KB
test_11.txt AC 44 ms 2316 KB
test_12.txt AC 46 ms 2188 KB
test_13.txt AC 38 ms 1952 KB
test_14.txt AC 48 ms 2312 KB
test_15.txt AC 47 ms 2548 KB
test_16.txt AC 38 ms 1928 KB
test_17.txt AC 47 ms 2312 KB
test_18.txt AC 39 ms 2064 KB
test_19.txt AC 44 ms 2188 KB
test_20.txt AC 42 ms 2296 KB
test_21.txt AC 771 ms 25740 KB
test_22.txt AC 759 ms 25100 KB
test_23.txt AC 787 ms 25980 KB
test_24.txt AC 798 ms 25144 KB
test_25.txt AC 797 ms 25736 KB
test_26.txt AC 776 ms 25796 KB
test_27.txt AC 687 ms 23688 KB
test_28.txt AC 850 ms 24844 KB
test_29.txt AC 31 ms 1268 KB
test_30.txt AC 35 ms 1804 KB
test_31.txt AC 144 ms 5388 KB
test_32.txt AC 34 ms 1804 KB
test_33.txt AC 569 ms 17548 KB
test_34.txt AC 32 ms 1416 KB
test_35.txt AC 37 ms 2060 KB
test_36.txt AC 768 ms 25096 KB
test_37.txt AC 884 ms 25852 KB
test_38.txt AC 776 ms 25744 KB
test_39.txt AC 789 ms 24844 KB
test_40.txt AC 804 ms 24760 KB
test_41.txt AC 635 ms 21320 KB
test_42.txt AC 782 ms 25080 KB
test_43.txt AC 651 ms 23700 KB