結果

問題 No.77 レンガのピラミッド
ユーザー ducktail
提出日時 2018-06-04 15:07:27
言語 Haskell
(9.10.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 362 bytes
コンパイル時間 3,168 ms
コンパイル使用メモリ 174,976 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-30 09:38:12
合計ジャッジ時間 4,403 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

import Control.Applicative ((<$>))

main :: IO ()
main = getLine >> solve <$> map read <$> words <$> getLine >>= print

solve :: [Int] -> Int
solve xs = sum $ zipWith f xs (pyramid xs)
  where pyramid xs = [1..h] ++ [h-1, h-2..1] ++ repeat 0
          where h = floor . sqrt . fromIntegral . sum $ xs
        f x y | x >= y = x - y
              | otherwise = 0
0