結果
| 問題 |
No.232 めぐるはめぐる (2)
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-07-19 22:11:35 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 1,000 ms |
| コード長 | 864 bytes |
| コンパイル時間 | 6,213 ms |
| コンパイル使用メモリ | 173,184 KB |
| 実行使用メモリ | 16,896 KB |
| 最終ジャッジ日時 | 2024-09-14 12:38:23 |
| 合計ジャッジ時間 | 8,049 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
コンパイルメッセージ
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
ソースコード
import Control.Monad
import Data.List
import Data.Function
import Data.Maybe
main = do
[t, a, b] <- liftM (map read . words) getLine
let f p = let xs = mapMaybe (g p) [0..t]
in guard (not (null xs)) >> return (maximumBy (compare `on` uncurry (+)) xs)
g p x = let y = x - p
in if x < p || x + y > t
then Nothing
else Just (x, y)
i = f a
j = f b
case liftM2 ((+) `on` (uncurry (+))) i j of
Nothing -> putStrLn "NO"
Just k
| k < t -> putStrLn "NO"
| otherwise -> do
putStrLn "YES"
let Just (u, d) = i
Just (r, l) = j
xs = replicate u "^" ++ replicate d "v" ++ replicate (t-u-d) ""
ys = replicate (t-l-r) "" ++ replicate l "<" ++ replicate r ">"
mapM_ putStrLn $ zipWith (++) xs ys
tottoripaper