結果

問題 No.2509 Beam Shateki
ユーザー ニックネームニックネーム
提出日時 2023-10-20 23:19:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,038 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 11,960 KB
実行使用メモリ 17,544 KB
最終ジャッジ日時 2023-10-20 23:20:17
合計ジャッジ時間 5,835 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,296 KB
testcase_01 AC 26 ms
10,296 KB
testcase_02 AC 26 ms
10,296 KB
testcase_03 AC 37 ms
11,780 KB
testcase_04 AC 37 ms
11,780 KB
testcase_05 AC 39 ms
11,780 KB
testcase_06 AC 39 ms
11,780 KB
testcase_07 AC 42 ms
11,780 KB
testcase_08 AC 38 ms
11,780 KB
testcase_09 AC 44 ms
11,780 KB
testcase_10 AC 38 ms
11,780 KB
testcase_11 AC 37 ms
11,780 KB
testcase_12 AC 36 ms
11,780 KB
testcase_13 AC 69 ms
17,544 KB
testcase_14 AC 68 ms
17,544 KB
testcase_15 AC 70 ms
17,544 KB
testcase_16 AC 69 ms
17,544 KB
testcase_17 AC 72 ms
17,544 KB
testcase_18 AC 76 ms
17,544 KB
testcase_19 AC 72 ms
17,544 KB
testcase_20 AC 71 ms
17,544 KB
testcase_21 AC 72 ms
17,544 KB
testcase_22 AC 73 ms
17,544 KB
testcase_23 AC 75 ms
17,544 KB
testcase_24 AC 73 ms
17,544 KB
testcase_25 AC 71 ms
17,544 KB
testcase_26 AC 83 ms
17,544 KB
testcase_27 AC 72 ms
17,544 KB
testcase_28 AC 72 ms
17,544 KB
testcase_29 AC 75 ms
17,544 KB
testcase_30 AC 71 ms
17,544 KB
testcase_31 AC 72 ms
17,544 KB
testcase_32 AC 71 ms
17,544 KB
testcase_33 AC 30 ms
10,724 KB
testcase_34 AC 44 ms
12,520 KB
testcase_35 AC 54 ms
14,192 KB
testcase_36 AC 34 ms
11,516 KB
testcase_37 AC 29 ms
10,396 KB
testcase_38 AC 35 ms
11,516 KB
testcase_39 AC 34 ms
11,516 KB
testcase_40 AC 46 ms
12,572 KB
testcase_41 AC 27 ms
10,324 KB
testcase_42 AC 36 ms
11,780 KB
testcase_43 AC 57 ms
15,476 KB
testcase_44 AC 63 ms
16,180 KB
testcase_45 AC 35 ms
11,252 KB
testcase_46 AC 38 ms
12,044 KB
testcase_47 AC 71 ms
16,188 KB
testcase_48 AC 41 ms
12,296 KB
testcase_49 AC 48 ms
13,344 KB
testcase_50 AC 48 ms
13,100 KB
testcase_51 AC 29 ms
10,624 KB
testcase_52 AC 43 ms
12,836 KB
testcase_53 AC 26 ms
10,296 KB
testcase_54 AC 27 ms
10,296 KB
testcase_55 AC 27 ms
10,304 KB
testcase_56 AC 27 ms
10,304 KB
testcase_57 AC 26 ms
10,304 KB
testcase_58 AC 27 ms
10,304 KB
testcase_59 AC 26 ms
10,304 KB
testcase_60 AC 27 ms
10,304 KB
testcase_61 AC 25 ms
10,304 KB
testcase_62 AC 26 ms
10,304 KB
testcase_63 AC 26 ms
10,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w = map(int,input().split())
a = [[0]*(w+3)]+[[0]+list(map(int,input().split()))+[0,0] for _ in range(h)]+[[0]*(w+3),[0]*(w+3)]
s = []; ans = 0
for x in range(h+2):
    for dx in range(-1,2):
        px = x+dx; py = 1; t = set(); u = 0
        while a[px][py]: t.add((px,py)); u += a[px][py]; px += dx; py += 1
        s.append((u,t))
for y in range(w+2):
    for dy in range(-1,2):
        px = 1; py = y+dy; t = set(); u = 0
        while a[px][py]: t.add((px,py)); u += a[px][py]; px += 1; py += dy
        s.append((u,t))
for x in range(h+2):
    dx = 1; px = x+dx; py = w; t = set(); u = 0
    while a[px][py]: t.add((px,py)); u += a[px][py]; px += dx; py -= 1
    s.append((u,t))
for y in range(w+2):
    dy = 1; px = h; py = y+dy; t = set(); u = 0
    while a[px][py]: t.add((px,py)); u += a[px][py]; px -= 1; py += dy
    s.append((u,t))
s.sort(reverse=True)
for i in range(len(s)-1):
    for j in range(i+1,len(s)):
        if s[i][0]+s[j][0]<ans: break
        ans = max(ans,sum(a[x][y] for x,y in s[i][1]|s[j][1]))
print(ans)
0