Submission #1611791


Source Code Expand

N = int(input())
D = []
for i in range(N):
    D.append(list(map(int,input().split())))
Q = int(input())
P = []
for i in range(Q):
    P.append(int(input()))

dp = [[0 for i in range(N+1)] for i in range(N+1)]

for i in range(N)[::-1]:
    for j in range(N)[::-1]:
        dp[i][j] = dp[i + 1][j] + dp[i][j + 1] - dp[i + 1][j + 1] + D[i][j]

score = [0 for i in range(N**2 + 1)]

for i in range(N):
    for j in range(N):
        for k in range(i+1,N+1):
            for l in range(j+1,N+1):
                s = (k-i)*(l-j)
                score[s] = max(score[s],dp[i][j] - dp[k][j] - dp[i][l] + dp[k][l])

for i in range(1,len(score)):
    score[i] = max(score[i-1],score[i])

for i in P:
    print(score[i])

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User hukuhuku11111
Language Python (3.4.3)
Score 100
Code Size 738 Byte
Status AC
Exec Time 1466 ms
Memory 3572 KB

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 50 / 50 50 / 50
Status
AC × 18
AC × 20
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 792 ms 3188 KB
rand1.txt AC 437 ms 3316 KB
rand2.txt AC 724 ms 3444 KB
rand3.txt AC 160 ms 3188 KB
rand4.txt AC 20 ms 3064 KB
rand_max0.txt AC 1426 ms 3572 KB
rand_max1.txt AC 1388 ms 3572 KB
rand_max2.txt AC 1357 ms 3572 KB
rand_max3.txt AC 1390 ms 3572 KB
rand_max4.txt AC 1466 ms 3572 KB
s1.txt AC 17 ms 3064 KB
s2.txt AC 17 ms 3064 KB
sub0.txt AC 17 ms 3064 KB
sub1.txt AC 17 ms 3064 KB
sub2.txt AC 17 ms 3064 KB
sub_rand_max0.txt AC 18 ms 3064 KB
sub_rand_max1.txt AC 18 ms 3064 KB
sub_rand_max2.txt AC 17 ms 3064 KB
sub_rand_max3.txt AC 18 ms 3064 KB
sub_rand_min0.txt AC 17 ms 3064 KB