Submission #4078641


Source Code Expand

#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
a,b = LS()
c = int(a+b)
for i in range(1,1000):
    if i * i == c:
        print("Yes")
        quit()
print("No")
"""

#B
"""
a,b = LI()
if a*b <= 0:
    print("Zero")
else:
    if b < 0:
        if (a-b) %2 == 1:
            print("Positive")
        else:
            print("Negative")
    else:
        print("Positive")
"""

#C
"""
n = II()
s = SR(n)
march = [[] for i in range(5)]
ch = list("MARCH")
for i in s:
    for j in range(5):
        if i[0] == ch[j]:
            march[j].append(i)
ans = 0
for i in range(5):
    for j in range(i):
        for k in range(j):
            if len(march[i])*len(march[j])*len(march[k]) == 0:
                break
            ans += len(march[i])*len(march[j])*len(march[k])
print(ans)
"""

#D
n = II()
d = LIR(n)
q = II()
p = IIR(q)
d.insert(0,[0 for i in range(n+1)])
for i in range(n):
    d[i+1].insert(0,0)
for i in range(n):
    for j in range(n):
        d[i+1][j+1] += d[i+1][j]+d[i][j+1]-d[i][j]
for i in p:
    ans = 0
    for a in range(n+1):
        for b in range(n+1):
            for c in range(a):
                for e in range(b):
                    if (a-c)*(b-e) <= i:
                        ans = max(ans, d[a][b]-d[c][b]-d[a][e]+d[c][e])
    print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User dn6049949
Language PyPy3 (2.4.0)
Score 50
Code Size 1756 Byte
Status TLE
Exec Time 5262 ms
Memory 49780 KB

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 50 / 50 0 / 50
Status
AC × 18
AC × 13
TLE × 7
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 AC 4053 ms 44124 KB
rand1.txt TLE 5258 ms 46428 KB
rand2.txt TLE 5259 ms 49240 KB
rand3.txt AC 1101 ms 44764 KB
rand4.txt AC 218 ms 41200 KB
rand_max0.txt TLE 5258 ms 47448 KB
rand_max1.txt TLE 5262 ms 49508 KB
rand_max2.txt TLE 5257 ms 49780 KB
rand_max3.txt TLE 5259 ms 47448 KB
rand_max4.txt TLE 5258 ms 49132 KB
s1.txt AC 180 ms 38256 KB
s2.txt AC 170 ms 38256 KB
sub0.txt AC 183 ms 39280 KB
sub1.txt AC 198 ms 41072 KB
sub2.txt AC 195 ms 40176 KB
sub_rand_max0.txt AC 195 ms 40176 KB
sub_rand_max1.txt AC 198 ms 40176 KB
sub_rand_max2.txt AC 192 ms 40176 KB
sub_rand_max3.txt AC 191 ms 40176 KB
sub_rand_min0.txt AC 168 ms 38256 KB