結果

問題 No.232 めぐるはめぐる (2)
ユーザー tottoripapertottoripaper
提出日時 2015-07-19 22:11:35
言語 Haskell
(9.8.2)
結果
AC  
実行時間 52 ms / 1,000 ms
コード長 864 bytes
コンパイル時間 3,678 ms
コンパイル使用メモリ 162,124 KB
実行使用メモリ 19,156 KB
最終ジャッジ日時 2023-10-12 13:40:37
合計ジャッジ時間 5,157 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
19,064 KB
testcase_01 AC 42 ms
13,584 KB
testcase_02 AC 52 ms
19,156 KB
testcase_03 AC 52 ms
17,240 KB
testcase_04 AC 12 ms
13,664 KB
testcase_05 AC 2 ms
6,880 KB
testcase_06 AC 2 ms
6,960 KB
testcase_07 AC 5 ms
9,076 KB
testcase_08 AC 32 ms
13,848 KB
testcase_09 AC 12 ms
13,632 KB
testcase_10 AC 3 ms
6,984 KB
testcase_11 AC 2 ms
6,984 KB
testcase_12 AC 3 ms
6,972 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 3 ms
6,876 KB
testcase_15 AC 3 ms
7,040 KB
testcase_16 AC 2 ms
6,872 KB
testcase_17 AC 3 ms
6,880 KB
testcase_18 AC 4 ms
8,152 KB
testcase_19 AC 2 ms
6,968 KB
testcase_20 AC 2 ms
6,820 KB
testcase_21 AC 2 ms
6,920 KB
testcase_22 AC 3 ms
6,904 KB
testcase_23 AC 2 ms
6,884 KB
testcase_24 AC 2 ms
6,928 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

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
        
0