結果
| 問題 |
No.596 郵便配達
|
| コンテスト | |
| ユーザー |
test
|
| 提出日時 | 2017-11-11 14:47:47 |
| 言語 | Haskell (9.10.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 468 bytes |
| コンパイル時間 | 7,713 ms |
| コンパイル使用メモリ | 174,208 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-24 19:05:13 |
| 合計ジャッジ時間 | 7,148 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 18 RE * 3 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:5:1: warning: [GHC-94817] [-Wtabs]
Tab character found here, and in 18 further locations.
Suggested fix: Please use spaces instead.
|
5 | [n, p] <- map read . words <$> getLine
| ^^^^^^^^
Main.hs:10:48: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
10 | solve x p = minPair $ foldl' f (0, p) $ zip x (tail x)
| ^^^^
[2 of 2] Linking a.out
ソースコード
import Data.List main :: IO () main = do [n, p] <- map read . words <$> getLine h <- map read . words <$> getLine print $ solve h p solve :: [Int] -> Int -> Int solve x p = minPair $ foldl' f (0, p) $ zip x (tail x) where f :: (Int, Int) -> (Int, Int) -> (Int, Int) f (dp0, dp1) (h0, h1) = (v0, v1) where v0 = min (dp0 + max 0 (h1 - h0)) (dp1 + p) v1 = min (dp1 + max 0 (h0 - h1)) (dp0 + p) minPair :: (Int, Int) -> Int minPair (x, y) = min x y
test