結果
| 問題 | No.1285 ゴミ捨て |
| コンテスト | |
| ユーザー |
kou_kkk
|
| 提出日時 | 2026-05-22 17:11:26 |
| 言語 | Haskell (9.14.1) |
| 結果 |
AC
|
| 実行時間 | 245 ms / 2,000 ms |
| コード長 | 1,313 bytes |
| 記録 | |
| コンパイル時間 | 5,962 ms |
| コンパイル使用メモリ | 194,560 KB |
| 実行使用メモリ | 25,216 KB |
| 最終ジャッジ日時 | 2026-05-22 17:11:41 |
| 合計ジャッジ時間 | 9,196 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:47:24: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Prelude, but defined in GHC.Internal.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use "Data.List.NonEmpty"."
|
47 | next = head xs
| ^^^^
Main.hs:48:23: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Prelude, but defined in GHC.Internal.List):
"This is a partial function, it throws an error on empty lists. Replace it with 'drop' 1, or use pattern matching or 'GHC.Internal.Data.List.uncons' instead. Consider refactoring to use "Data.List.NonEmpty"."
|
48 | xs' = tail xs
| ^^^^
[2 of 2] Linking a.out
ソースコード
module Main where
import Data.List (sortBy)
type Input = [Int]
type Output = Int
data Model = Model
{ current :: Int
, remain :: [Int]
, tops :: [Int]
}
parse :: String -> Input
parse s =
let
(_ : a) =
map read (lines s)
in
a
solve :: Input -> Output
solve input =
let
(x : xs) =
sortBy (flip compare) input
model' =
run
Model
{ current = x
, remain = xs
, tops = []
}
in
length (tops model')
run :: Model -> Model
run model =
case model of
Model x [] tops ->
model { tops = run' x tops }
Model x xs tops ->
let
next = head xs
xs' = tail xs
in
run
Model
{ current = next
, remain = xs'
, tops = run' x tops
}
run' :: Int -> [Int] -> [Int]
run' x [] = [x]
run' x (y : ys) =
if x + 1 < y then
x : ys
else
y : run' x ys
render :: Output -> String
render = show
main :: IO ()
main =
interact
( render
. solve
. parse
)
kou_kkk