Submission #52874954


Source Code Expand

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE FlexibleContexts #-}
{-# HLINT ignore "Use lambda-case" #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

module Main where

import Control.Monad (replicateM)
import qualified Data.ByteString.Char8 as BC
import qualified Data.Char as C
import qualified Data.List as L
import Debug.Trace (trace)

main :: IO ()
main = do
  _ <- readLn @Int
  as <- readInputInts

  print $ L.length $ solve [] as

solve :: [Int] -> [Int] -> [Int]
solve res [] = res
solve [] (hAs : tAs) = solve [hAs] tAs
solve res@(hRes : tRes) (hAs : tAs) =
  if hRes /= hAs
    then solve (hAs : res) tAs
    else solve tRes ((hRes + 1) : tAs)

readInputInts :: IO [Int]
readInputInts = L.unfoldr (BC.readInt . BC.dropWhile C.isSpace) <$> BC.getLine

Submission Info

Submission Time
Task C - Merge the balls
User flowert
Language Haskell (GHC 9.4.5)
Score 250
Code Size 892 Byte
Status AC
Exec Time 42 ms
Memory 28420 KiB

Compile Error

app/Main.hs:11:1: warning: [-Wunused-imports]
    The import of ‘Control.Monad’ is redundant
      except perhaps to import instances from ‘Control.Monad’
    To import instances alone, use: import Control.Monad()
   |
11 | import Control.Monad (replicateM)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

app/Main.hs:15:1: warning: [-Wunused-imports]
    The import of ‘Debug.Trace’ is redundant
      except perhaps to import instances from ‘Debug.Trace’
    To import instances alone, use: import Debug.Trace()
   |
15 | import Debug.Trace (trace)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 250 / 250
Status
AC × 2
AC × 38
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
Case Name Status Exec Time Memory
example_00.txt AC 2 ms 7092 KiB
example_01.txt AC 2 ms 6808 KiB
hand_00.txt AC 21 ms 16592 KiB
hand_01.txt AC 10 ms 14768 KiB
hand_02.txt AC 11 ms 14752 KiB
hand_03.txt AC 32 ms 27620 KiB
hand_04.txt AC 31 ms 27684 KiB
hand_05.txt AC 11 ms 14396 KiB
hand_06.txt AC 31 ms 27592 KiB
hand_07.txt AC 2 ms 7028 KiB
hand_08.txt AC 2 ms 6860 KiB
hand_09.txt AC 2 ms 7128 KiB
hand_10.txt AC 2 ms 7072 KiB
random_00.txt AC 31 ms 18532 KiB
random_01.txt AC 21 ms 18476 KiB
random_02.txt AC 21 ms 18400 KiB
random_03.txt AC 21 ms 18452 KiB
random_04.txt AC 21 ms 18452 KiB
random_05.txt AC 31 ms 25820 KiB
random_06.txt AC 31 ms 25848 KiB
random_07.txt AC 31 ms 25796 KiB
random_08.txt AC 31 ms 26748 KiB
random_09.txt AC 32 ms 26728 KiB
random_10.txt AC 21 ms 17444 KiB
random_11.txt AC 21 ms 17444 KiB
random_12.txt AC 31 ms 27020 KiB
random_13.txt AC 31 ms 26064 KiB
random_14.txt AC 31 ms 26252 KiB
random_15.txt AC 31 ms 26660 KiB
random_16.txt AC 31 ms 25444 KiB
random_17.txt AC 31 ms 26332 KiB
random_18.txt AC 31 ms 28396 KiB
random_19.txt AC 31 ms 28160 KiB
random_20.txt AC 42 ms 28316 KiB
random_21.txt AC 32 ms 28372 KiB
random_22.txt AC 31 ms 28420 KiB
random_23.txt AC 31 ms 28336 KiB
random_24.txt AC 32 ms 28308 KiB