結果

問題 No.2509 Beam Shateki
ユーザー hirayuu_ychirayuu_yc
提出日時 2023-10-20 21:34:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,028 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-09-20 17:36:23
合計ジャッジ時間 6,198 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,144 KB
testcase_01 AC 45 ms
54,144 KB
testcase_02 AC 50 ms
53,760 KB
testcase_03 AC 88 ms
73,728 KB
testcase_04 AC 79 ms
73,728 KB
testcase_05 AC 80 ms
73,856 KB
testcase_06 AC 82 ms
74,112 KB
testcase_07 AC 83 ms
74,240 KB
testcase_08 AC 80 ms
74,112 KB
testcase_09 AC 81 ms
73,984 KB
testcase_10 AC 80 ms
73,728 KB
testcase_11 AC 80 ms
74,068 KB
testcase_12 AC 81 ms
74,240 KB
testcase_13 AC 87 ms
76,920 KB
testcase_14 AC 92 ms
76,800 KB
testcase_15 AC 90 ms
76,752 KB
testcase_16 AC 90 ms
76,800 KB
testcase_17 AC 92 ms
77,056 KB
testcase_18 AC 88 ms
76,800 KB
testcase_19 AC 88 ms
76,800 KB
testcase_20 AC 89 ms
77,056 KB
testcase_21 AC 88 ms
76,840 KB
testcase_22 AC 88 ms
77,056 KB
testcase_23 AC 87 ms
76,672 KB
testcase_24 AC 88 ms
76,800 KB
testcase_25 AC 88 ms
76,800 KB
testcase_26 AC 90 ms
76,760 KB
testcase_27 AC 91 ms
76,672 KB
testcase_28 AC 85 ms
76,672 KB
testcase_29 AC 89 ms
76,732 KB
testcase_30 AC 86 ms
76,800 KB
testcase_31 WA -
testcase_32 AC 88 ms
76,800 KB
testcase_33 AC 61 ms
65,536 KB
testcase_34 AC 78 ms
71,424 KB
testcase_35 AC 79 ms
73,600 KB
testcase_36 AC 69 ms
69,760 KB
testcase_37 AC 44 ms
54,656 KB
testcase_38 AC 69 ms
69,632 KB
testcase_39 AC 66 ms
69,120 KB
testcase_40 AC 73 ms
71,424 KB
testcase_41 AC 44 ms
54,528 KB
testcase_42 AC 77 ms
73,856 KB
testcase_43 AC 76 ms
74,496 KB
testcase_44 AC 76 ms
74,624 KB
testcase_45 AC 68 ms
69,120 KB
testcase_46 AC 70 ms
70,272 KB
testcase_47 AC 84 ms
74,864 KB
testcase_48 AC 74 ms
71,040 KB
testcase_49 AC 75 ms
72,064 KB
testcase_50 AC 77 ms
73,216 KB
testcase_51 AC 61 ms
65,280 KB
testcase_52 AC 75 ms
71,552 KB
testcase_53 AC 42 ms
54,144 KB
testcase_54 AC 42 ms
54,144 KB
testcase_55 AC 42 ms
54,528 KB
testcase_56 AC 41 ms
54,272 KB
testcase_57 AC 40 ms
54,144 KB
testcase_58 WA -
testcase_59 AC 41 ms
54,144 KB
testcase_60 WA -
testcase_61 AC 41 ms
54,016 KB
testcase_62 WA -
testcase_63 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy
deg=[(0,1),(1,0),(1,1),(-1,1)]
H,W=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
beam=[]
for i in range(W+1):
    for xd,yd in deg:
        x=i
        y=0
        x+=xd
        y+=yd
        now=0
        while 1<=x<=W and 1<=y<=H:
            now+=A[y-1][x-1]
            x+=xd
            y+=yd
        if now!=0:
            beam.append((now,i,0,xd,yd))
for i in range(H+1):
    for xd,yd in deg:
        x=0
        y=i
        x+=xd
        y+=yd
        now=0
        while 1<=x<=W and 1<=y<=H:
            now+=A[y-1][x-1]
            x+=xd
            y+=yd
        if now!=0:
            beam.append((now,0,i,xd,yd))
ap=deepcopy(A)
beam.sort(reverse=True)
x=beam[0][1]
y=beam[0][2]
xd=beam[0][3]
yd=beam[0][4]
x+=xd
y+=yd
ans=beam[0][0]
while 1<=x<=W and 1<=y<=H:
    A[y-1][x-1]=0
    x+=xd
    y+=yd
maxi=0
for i in range(W+1):
    for xd,yd in deg:
        x=i
        y=0
        x+=xd
        y+=yd
        now=0
        while 1<=x<=W and 1<=y<=H:
            now+=A[y-1][x-1]
            x+=xd
            y+=yd
        maxi=max(maxi,now)
for i in range(H+1):
    for xd,yd in deg:
        x=0
        y=i
        x+=xd
        y+=yd
        now=0
        while 1<=x<=W and 1<=y<=H:
            now+=A[y-1][x-1]
            x+=xd
            y+=yd
        maxi=max(maxi,now)
ans1=ans+maxi
A=deepcopy(ap)
x=beam[1][1]
y=beam[1][2]
xd=beam[1][3]
yd=beam[1][4]
x+=xd
y+=yd
ans=beam[1][0]
while 1<=x<=W and 1<=y<=H:
    A[y-1][x-1]=0
    x+=xd
    y+=yd
maxi=0
for i in range(W+1):
    for xd,yd in deg:
        x=i
        y=0
        x+=xd
        y+=yd
        now=0
        while 1<=x<=W and 1<=y<=H:
            now+=A[y-1][x-1]
            x+=xd
            y+=yd
        maxi=max(maxi,now)
for i in range(H+1):
    for xd,yd in deg:
        x=0
        y=i
        x+=xd
        y+=yd
        now=0
        while 1<=x<=W and 1<=y<=H:
            now+=A[y-1][x-1]
            x+=xd
            y+=yd
        maxi=max(maxi,now)
print(max(ans1,ans+maxi))
0