Submission #1760909


Source Code Expand

import Control.Monad

type Board = [[Int]]

scores :: Board -> Int -> [Int]
scores board p = do
    let n = length board
    x <- [0 .. n - 1]
    y <- [0 .. n - 1]
    w <- [1 .. (n - x)]
    h <- [1 .. (n - y)]
    guard (w * h <= p)
    return $ sum [(board !! j) !! i | i <- [x .. (x + w - 1)], j <- [y .. (y + h - 1)]]

maxScore :: Board -> Int -> Int
maxScore board p = maximum $ scores board p

main :: IO ()
main = do
    n <- readLn :: IO Int
    board <- mapM (\_ -> map (read :: String -> Int) . words <$> getLine) [1..n]
    q <- readLn :: IO Int
    mapM_ (\_ -> do
        p <- readLn :: IO Int
        print $ maxScore board p
        ) [1..q]

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User atctk
Language Haskell (GHC 7.10.3)
Score 50
Code Size 685 Byte
Status TLE
Exec Time 5255 ms
Memory 2300 KB

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 50 / 50 0 / 50
Status
AC × 18
AC × 11
TLE × 9
Set Name Test Cases
Subtask1 sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt
Subtask2 rand0.txt, rand1.txt, rand2.txt, rand3.txt, rand4.txt, rand_max0.txt, rand_max1.txt, rand_max2.txt, rand_max3.txt, rand_max4.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt
Case Name Status Exec Time Memory
rand0.txt TLE 5255 ms 2300 KB
rand1.txt TLE 5255 ms 2300 KB
rand2.txt TLE 5255 ms 2300 KB
rand3.txt TLE 5255 ms 2300 KB
rand4.txt AC 174 ms 1020 KB
rand_max0.txt TLE 5255 ms 2300 KB
rand_max1.txt TLE 5255 ms 2300 KB
rand_max2.txt TLE 5255 ms 2300 KB
rand_max3.txt TLE 5255 ms 2300 KB
rand_max4.txt TLE 5255 ms 2300 KB
s1.txt AC 1 ms 508 KB
s2.txt AC 1 ms 508 KB
sub0.txt AC 3 ms 892 KB
sub1.txt AC 3 ms 1020 KB
sub2.txt AC 3 ms 1020 KB
sub_rand_max0.txt AC 3 ms 1020 KB
sub_rand_max1.txt AC 3 ms 1020 KB
sub_rand_max2.txt AC 3 ms 892 KB
sub_rand_max3.txt AC 3 ms 892 KB
sub_rand_min0.txt AC 1 ms 508 KB