結果

問題 No.5 数字のブロック
ユーザー mtwtkmanmtwtkman
提出日時 2023-05-15 19:29:14
言語 Haskell
(9.8.2)
結果
AC  
実行時間 972 ms / 5,000 ms
コード長 698 bytes
コンパイル時間 6,843 ms
コンパイル使用メモリ 161,036 KB
実行使用メモリ 17,808 KB
最終ジャッジ日時 2023-08-20 19:47:41
合計ジャッジ時間 12,854 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,192 KB
testcase_01 AC 3 ms
7,268 KB
testcase_02 AC 2 ms
7,128 KB
testcase_03 AC 352 ms
16,832 KB
testcase_04 AC 222 ms
15,340 KB
testcase_05 AC 592 ms
16,864 KB
testcase_06 AC 242 ms
15,632 KB
testcase_07 AC 172 ms
14,900 KB
testcase_08 AC 312 ms
15,752 KB
testcase_09 AC 52 ms
14,972 KB
testcase_10 AC 702 ms
16,808 KB
testcase_11 AC 162 ms
15,340 KB
testcase_12 AC 382 ms
15,788 KB
testcase_13 AC 572 ms
16,812 KB
testcase_14 AC 3 ms
8,276 KB
testcase_15 AC 6 ms
10,548 KB
testcase_16 AC 622 ms
16,776 KB
testcase_17 AC 862 ms
17,780 KB
testcase_18 AC 753 ms
16,764 KB
testcase_19 AC 972 ms
17,808 KB
testcase_20 AC 2 ms
7,424 KB
testcase_21 AC 3 ms
7,144 KB
testcase_22 AC 2 ms
7,240 KB
testcase_23 AC 2 ms
7,308 KB
testcase_24 AC 6 ms
11,340 KB
testcase_25 AC 12 ms
11,544 KB
testcase_26 AC 2 ms
7,384 KB
testcase_27 AC 3 ms
7,296 KB
testcase_28 AC 2 ms
7,240 KB
testcase_29 AC 222 ms
15,284 KB
testcase_30 AC 62 ms
14,240 KB
testcase_31 AC 2 ms
7,264 KB
testcase_32 AC 3 ms
7,172 KB
testcase_33 AC 3 ms
7,204 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List (sort)

split :: String -> [String]
split = go ("", [])
  where
    go :: (String, [String]) -> String -> [String]
    go (a, acc) "" = acc <> [a]
    go (a, acc) (' ' : xs) = go ("", acc <> [a]) xs
    go (a, acc) (x : xs) = go (a <> [x], acc) xs

prompt :: IO [String]
prompt = do split <$> getLine

solve :: Int -> Int -> [Int] -> Int
solve l n ws = go 0 l (sort ws)
  where
    go :: Int -> Int -> [Int] -> Int
    go c acc [] = c
    go c 0 _ = c
    go c acc (x : xs) = if acc < x then c else go (c + 1) (acc - x) xs

main :: IO ()
main = do
  l :: Int <- read . head <$> prompt
  n :: Int <- read . head <$> prompt
  ws :: [Int] <- map read <$> prompt
  print $ solve l n ws
0