結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-08-19 12:30:51 |
| 言語 | Haskell (9.14.1) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 5,000 ms |
| + 197µs | |
| コード長 | 484 bytes |
| 記録 | |
| コンパイル時間 | 6,689 ms |
| コンパイル使用メモリ | 194,176 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2026-08-19 12:31:00 |
| 合計ジャッジ時間 | 7,220 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Data.List (sort)
main :: IO ()
main = do
input <- getContents
let (k:_:xs) = map read (words input)
-- 1. sort xs -> Sort items lowest to highest
-- 2. scanl (+) 0 -> Create running totals: [0, a1, a1+a2, ...]
-- 3. takeWhile (<= k) -> Keep only the totals within budget
-- 4. length (...) - 1 -> Count them (minus 1 for the initial 0)
print $ length (takeWhile (<= k) (scanl (+) 0 (sort xs))) - 1
vjudge1