結果
| 問題 | No.131 マンハッタン距離 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-25 14:29:19 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 389 bytes |
| 記録 | |
| コンパイル時間 | 7,407 ms |
| コンパイル使用メモリ | 173,568 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 08:46:04 |
| 合計ジャッジ時間 | 2,719 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
getSmall x y = if x < y then x else y
solve [x,y,d]
| d == 0 = 1
| m < d = 0
| x < d && y < d = m - d + 1
| x < d || y < d = (getSmall x y) + 1
| otherwise = d + 1
where
m = (abs x) + (abs y) -- マンハッタン距離
main = do
xyd <- map (abs . read :: String -> Int) . words <$> getLine
print $ solve xyd