Submission #1612204


Source Code Expand

# coding:utf-8

import numpy as np

N = int(input())
D = []
for i in range(N):
    D.append([int(x) for x in input().split(' ')])
D = np.array(D)

Q = int(input())
P = []
for i in range(Q):
    P.append(int(input()))

for i in P:
    maximum = 0
    for j in range(N, 0, -1):
        if i // j == 1:
            for k in range(0, N):
                for l in range(0, N - j + 1):
                    x = np.sum(D[k, l: l + j])
                    y = np.sum(D[l: l + j, k])
                    if x > y:
                        if x > maximum:
                            maximum = x
                    elif y > maximum:
                        maximum = y
            else:
                pass
        elif i // j > 1:
            if i // j > j:
                break
            else:
                for k in range(0, N - (i // j) + 1):
                    for l in range(0, N - j + 1):
                        x = np.sum(D[k: k + (i // j), l:l + j])
                        y = np.sum(D[l: l + j, k: k + (i // j)])
                        if x > y:
                            if x > maximum:
                                maximum = x
                        elif y > maximum:
                            maximum = y
    print(maximum)

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User macho_uno
Language Python (3.4.3)
Score 50
Code Size 1288 Byte
Status TLE
Exec Time 5260 ms
Memory 14452 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 5260 ms 14452 KB
rand1.txt TLE 5260 ms 12296 KB
rand2.txt TLE 5260 ms 12420 KB
rand3.txt TLE 5260 ms 14328 KB
rand4.txt AC 274 ms 12424 KB
rand_max0.txt TLE 5260 ms 14328 KB
rand_max1.txt TLE 5260 ms 12420 KB
rand_max2.txt TLE 5260 ms 12420 KB
rand_max3.txt TLE 5260 ms 14452 KB
rand_max4.txt TLE 5260 ms 14328 KB
s1.txt AC 146 ms 12420 KB
s2.txt AC 145 ms 12420 KB
sub0.txt AC 148 ms 12296 KB
sub1.txt AC 150 ms 12296 KB
sub2.txt AC 152 ms 12296 KB
sub_rand_max0.txt AC 155 ms 12296 KB
sub_rand_max1.txt AC 154 ms 12296 KB
sub_rand_max2.txt AC 156 ms 12424 KB
sub_rand_max3.txt AC 154 ms 12296 KB
sub_rand_min0.txt AC 145 ms 12296 KB