Submission #54342566
Source Code Expand
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeApplications #-}
{-# HLINT ignore "Use lambda-case" #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
module Main where
import Control.Monad (replicateM)
import Data.Bits
import qualified Data.ByteString.Char8 as BC
import qualified Data.Char as C
import qualified Data.List as L
main :: IO ()
main =
do
[_, m] <- readInputInts
hs <- readInputInts
let res =
L.foldl'
( \(m', count) h ->
if m' >= h
then (m' - h, count + 1)
else (0, count)
)
(m, 0)
hs
print $ snd res
readInputInts :: IO [Int]
readInputInts = L.unfoldr (BC.readInt . BC.dropWhile C.isSpace) <$> BC.getLine
Submission Info
| Submission Time | |
|---|---|
| Task | A - Sanitize Hands |
| User | flowert |
| Language | Haskell (GHC 9.4.5) |
| Score | 100 |
| Code Size | 852 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 6924 KiB |
Compile Error
app/Main.hs:10: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()
|
10 | import Control.Monad (replicateM)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:11:1: warning: [-Wunused-imports]
The import of ‘Data.Bits’ is redundant
except perhaps to import instances from ‘Data.Bits’
To import instances alone, use: import Data.Bits()
|
11 | import Data.Bits
| ^^^^^^^^^^^^^^^^
app/Main.hs:32:5: warning: [-Wtype-defaults]
• Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraints
(Show a0) arising from a use of ‘print’ at app/Main.hs:32:5-9
(Num a0) arising from a use of ‘+’ at app/Main.hs:26:39
• In the first argument of ‘($)’, namely ‘print’
In a stmt of a 'do' block: print $ snd res
In the expression:
do [_, m] <- readInputInts
hs <- readInputInts
let res = L.foldl' (\ (m', count) h -> ...) ... hs
print $ snd res
|
32 | print $ snd res
| ^^^^^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 100 / 100 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt, example_02.txt |
| All | example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 6920 KiB |
| example_01.txt | AC | 1 ms | 6892 KiB |
| example_02.txt | AC | 1 ms | 6860 KiB |
| hand_00.txt | AC | 1 ms | 6676 KiB |
| hand_01.txt | AC | 1 ms | 6828 KiB |
| hand_02.txt | AC | 1 ms | 6912 KiB |
| hand_03.txt | AC | 1 ms | 6876 KiB |
| hand_04.txt | AC | 1 ms | 6764 KiB |
| hand_05.txt | AC | 1 ms | 6676 KiB |
| random_00.txt | AC | 1 ms | 6824 KiB |
| random_01.txt | AC | 1 ms | 6904 KiB |
| random_02.txt | AC | 1 ms | 6876 KiB |
| random_03.txt | AC | 1 ms | 6864 KiB |
| random_04.txt | AC | 1 ms | 6900 KiB |
| random_05.txt | AC | 1 ms | 6924 KiB |
| random_06.txt | AC | 1 ms | 6860 KiB |
| random_07.txt | AC | 1 ms | 6872 KiB |
| random_08.txt | AC | 1 ms | 6832 KiB |
| random_09.txt | AC | 1 ms | 6892 KiB |