結果
| 問題 |
No.2509 Beam Shateki
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-20 21:39:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,585 bytes |
| コンパイル時間 | 210 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 86,576 KB |
| 最終ジャッジ日時 | 2024-09-20 17:45:49 |
| 合計ジャッジ時間 | 23,377 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 WA * 5 |
ソースコード
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)
ans1=0
for p in range(len(beam)):
A=deepcopy(ap)
x=beam[p][1]
y=beam[p][2]
xd=beam[p][3]
yd=beam[p][4]
x+=xd
y+=yd
ans=beam[p][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=max(ans1,ans+maxi)
print(ans1)