結果
| 問題 |
No.572 妖精の演奏
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-07 01:19:18 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 556 bytes |
| コンパイル時間 | 4,793 ms |
| コンパイル使用メモリ | 172,160 KB |
| 実行使用メモリ | 10,368 KB |
| 最終ジャッジ日時 | 2024-11-17 03:13:17 |
| 合計ジャッジ時間 | 5,677 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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
ソースコード
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad
import Control.Applicative
import Data.List
main :: IO ()
main = do
(n :: Int) <- readLn
(m :: Int) <- readLn
a <- map (map read . words) <$> replicateM m getLine
print . maximum . concat $ power m a (n - 1)
power :: Int -> [[Int]] -> Int -> [[Int]]
power n a b
| b == 1 = a
| even b = power n (multiply a a) (b `div` 2)
| otherwise = multiply a $ power n a (b - 1)
multiply :: [[Int]] -> [[Int]] -> [[Int]]
multiply a b = [[maximum $ zipWith (+) x y | y <- transpose b] | x <- a]