結果

問題 No.2509 Beam Shateki
ユーザー titiatitia
提出日時 2023-10-25 02:15:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 1,857 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 12,228 KB
実行使用メモリ 10,704 KB
最終ジャッジ日時 2023-10-25 02:15:13
合計ジャッジ時間 10,839 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,324 KB
testcase_01 AC 27 ms
10,324 KB
testcase_02 AC 28 ms
10,324 KB
testcase_03 AC 75 ms
10,412 KB
testcase_04 AC 77 ms
10,412 KB
testcase_05 AC 77 ms
10,412 KB
testcase_06 AC 75 ms
10,412 KB
testcase_07 AC 74 ms
10,412 KB
testcase_08 AC 77 ms
10,412 KB
testcase_09 AC 75 ms
10,412 KB
testcase_10 AC 81 ms
10,412 KB
testcase_11 AC 76 ms
10,412 KB
testcase_12 AC 78 ms
10,412 KB
testcase_13 AC 208 ms
10,704 KB
testcase_14 AC 217 ms
10,704 KB
testcase_15 AC 218 ms
10,704 KB
testcase_16 AC 220 ms
10,704 KB
testcase_17 AC 233 ms
10,704 KB
testcase_18 AC 216 ms
10,704 KB
testcase_19 AC 216 ms
10,704 KB
testcase_20 AC 220 ms
10,704 KB
testcase_21 AC 218 ms
10,704 KB
testcase_22 AC 243 ms
10,704 KB
testcase_23 AC 218 ms
10,704 KB
testcase_24 AC 219 ms
10,704 KB
testcase_25 AC 215 ms
10,704 KB
testcase_26 AC 216 ms
10,704 KB
testcase_27 AC 224 ms
10,704 KB
testcase_28 AC 243 ms
10,704 KB
testcase_29 AC 225 ms
10,704 KB
testcase_30 AC 215 ms
10,704 KB
testcase_31 AC 216 ms
10,704 KB
testcase_32 AC 215 ms
10,704 KB
testcase_33 AC 41 ms
10,336 KB
testcase_34 AC 103 ms
10,472 KB
testcase_35 AC 139 ms
10,524 KB
testcase_36 AC 68 ms
10,372 KB
testcase_37 AC 56 ms
10,332 KB
testcase_38 AC 71 ms
10,392 KB
testcase_39 AC 72 ms
10,368 KB
testcase_40 AC 110 ms
10,500 KB
testcase_41 AC 31 ms
10,328 KB
testcase_42 AC 80 ms
10,384 KB
testcase_43 AC 168 ms
10,556 KB
testcase_44 AC 188 ms
10,624 KB
testcase_45 AC 72 ms
10,380 KB
testcase_46 AC 93 ms
10,396 KB
testcase_47 AC 180 ms
10,624 KB
testcase_48 AC 93 ms
10,448 KB
testcase_49 AC 120 ms
10,476 KB
testcase_50 AC 132 ms
10,500 KB
testcase_51 AC 42 ms
10,336 KB
testcase_52 AC 100 ms
10,452 KB
testcase_53 AC 27 ms
10,324 KB
testcase_54 AC 28 ms
10,324 KB
testcase_55 AC 27 ms
10,324 KB
testcase_56 AC 27 ms
10,324 KB
testcase_57 AC 27 ms
10,324 KB
testcase_58 AC 27 ms
10,324 KB
testcase_59 AC 27 ms
10,324 KB
testcase_60 AC 33 ms
10,324 KB
testcase_61 AC 28 ms
10,324 KB
testcase_62 AC 28 ms
10,324 KB
testcase_63 AC 29 ms
10,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from collections import Counter

H,W=map(int,input().split())

A=[list(map(int,input().split())) for i in range(H)]

T=Counter()
Y=Counter()
P=Counter()
M=Counter()

for i in range(H):
    for j in range(W):
        T[i]+=A[i][j]
        Y[j]+=A[i][j]
        P[i+j]+=A[i][j]
        M[i-j]+=A[i][j]

ANS=0

for i in T:
    for j in T:
        if i==j:
            continue
        ANS=max(ANS,T[i]+T[j])

for i in Y:
    for j in Y:
        if i==j:
            continue
        ANS=max(ANS,Y[i]+Y[j])

for i in P:
    for j in P:
        if i==j:
            continue
        ANS=max(ANS,P[i]+P[j])

for i in M:
    for j in M:
        if i==j:
            continue
        ANS=max(ANS,M[i]+M[j])

for i in T:
    for j in Y:
        ANS=max(ANS,T[i]+Y[j]-A[i][j])

for i in T:
    for j in P:
        # x=i
        # x+y=j

        y=j-i

        if 0<=y<W:
            ANS=max(ANS,T[i]+P[j]-A[i][y])
        else:
            ANS=max(ANS,T[i]+P[j])


for i in T:
    for j in M:
        # x=i
        # x-y=j

        y=i-j

        if 0<=y<W:
            ANS=max(ANS,T[i]+M[j]-A[i][y])
        else:
            ANS=max(ANS,T[i]+M[j])

for i in Y:
    for j in P:
        # y=i
        # x+y=j

        x=j-i

        if 0<=x<H:
            ANS=max(ANS,Y[i]+P[j]-A[x][i])
        else:
            ANS=max(ANS,Y[i]+P[j])


for i in Y:
    for j in M:
        # y=i
        # x-y=j

        x=i+j

        if 0<=x<H:
            ANS=max(ANS,Y[i]+M[j]-A[x][i])
        else:
            ANS=max(ANS,Y[i]+M[j])

for i in P:
    for j in M:
        # x+y=i
        # x-y=j

        x=(i+j)/2
        y=(i-j)/2

        if int(x)==x and int(y)==y and 0<=x<H and 0<=y<W:
            x=int(x)
            y=int(y)
            ANS=max(ANS,P[i]+M[j]-A[x][y])
        else:
            ANS=max(ANS,P[i]+M[j])

print(ANS)


0