結果
| 問題 | No.572 妖精の演奏 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-07 01:19:18 |
| 言語 | Haskell (9.14.1) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 556 bytes |
| 記録 | |
| コンパイル時間 | 1,417 ms |
| コンパイル使用メモリ | 195,968 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2026-05-12 05:21:02 |
| 合計ジャッジ時間 | 2,860 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / tmp-judge_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/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]