結果

問題 No.2509 Beam Shateki
ユーザー 👑 timitimi
提出日時 2023-10-28 04:29:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,366 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 76,808 KB
最終ジャッジ日時 2023-10-28 04:30:06
合計ジャッジ時間 8,750 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,648 KB
testcase_01 AC 39 ms
53,648 KB
testcase_02 AC 39 ms
53,648 KB
testcase_03 AC 93 ms
76,396 KB
testcase_04 AC 89 ms
76,368 KB
testcase_05 AC 89 ms
76,368 KB
testcase_06 AC 89 ms
76,376 KB
testcase_07 AC 88 ms
76,368 KB
testcase_08 AC 110 ms
76,368 KB
testcase_09 AC 91 ms
76,396 KB
testcase_10 AC 90 ms
76,368 KB
testcase_11 AC 89 ms
76,368 KB
testcase_12 AC 89 ms
76,368 KB
testcase_13 AC 100 ms
76,388 KB
testcase_14 AC 100 ms
76,388 KB
testcase_15 AC 100 ms
76,396 KB
testcase_16 AC 100 ms
76,388 KB
testcase_17 AC 99 ms
76,396 KB
testcase_18 AC 100 ms
76,392 KB
testcase_19 AC 128 ms
76,392 KB
testcase_20 AC 101 ms
76,388 KB
testcase_21 AC 99 ms
76,388 KB
testcase_22 AC 104 ms
76,392 KB
testcase_23 AC 99 ms
76,392 KB
testcase_24 AC 99 ms
76,396 KB
testcase_25 AC 100 ms
76,388 KB
testcase_26 AC 99 ms
76,396 KB
testcase_27 AC 100 ms
76,392 KB
testcase_28 AC 99 ms
76,388 KB
testcase_29 AC 127 ms
76,392 KB
testcase_30 AC 100 ms
76,396 KB
testcase_31 AC 99 ms
76,392 KB
testcase_32 AC 99 ms
76,392 KB
testcase_33 AC 54 ms
66,232 KB
testcase_34 AC 98 ms
76,404 KB
testcase_35 AC 96 ms
76,428 KB
testcase_36 AC 84 ms
76,532 KB
testcase_37 AC 55 ms
66,512 KB
testcase_38 AC 83 ms
76,532 KB
testcase_39 AC 96 ms
76,788 KB
testcase_40 AC 103 ms
76,808 KB
testcase_41 AC 42 ms
53,648 KB
testcase_42 AC 85 ms
76,220 KB
testcase_43 AC 98 ms
76,480 KB
testcase_44 AC 105 ms
76,492 KB
testcase_45 AC 87 ms
76,220 KB
testcase_46 AC 88 ms
76,148 KB
testcase_47 AC 95 ms
76,412 KB
testcase_48 AC 94 ms
76,336 KB
testcase_49 AC 95 ms
76,368 KB
testcase_50 AC 96 ms
76,416 KB
testcase_51 AC 56 ms
66,228 KB
testcase_52 AC 93 ms
76,416 KB
testcase_53 AC 39 ms
53,648 KB
testcase_54 AC 40 ms
53,648 KB
testcase_55 AC 37 ms
53,648 KB
testcase_56 AC 37 ms
53,648 KB
testcase_57 AC 39 ms
53,648 KB
testcase_58 AC 38 ms
53,648 KB
testcase_59 AC 38 ms
53,648 KB
testcase_60 AC 37 ms
53,648 KB
testcase_61 AC 41 ms
53,648 KB
testcase_62 WA -
testcase_63 AC 39 ms
53,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W=map(int,input().split())
A=[]
B=[];C=[0]*W
D,E={},{}
for i in range(H):
  AA=list(map(int, input().split()))
  for j in range(W):
    C[j]+=AA[j]
    x=i+j
    if x not in D:
      D[x]=0
    y=i-j 
    if y not in E:
      E[y]=0
    D[x]+=AA[j];E[y]+=AA[j]
  A.append(AA)
  B.append(sum(AA))
if H==1 and W==1:
  print(AA[0])
  exit()
  
DD,EE=[],[]
for d in D:
  DD.append(D[d])
for e in E:
  EE.append(E[e])
BB=sorted(B)[::-1];CC=sorted(C)[::-1];DDD=sorted(DD)[::-1];EEE=sorted(EE)[::-1]
ans=0
if len(BB)>1:
  ans=max(ans,BB[0]+BB[1])
if len(CC)>1:
  ans=max(ans,CC[0]+CC[1])
if len(DD)>1:
  ans=max(ans,DDD[0]+DDD[1])
if len(EE)>1:
  ans=max(ans,EEE[0]+EEE[1])
  
for d in D:
  for e in E:
    if (d+e)%2==0 and (d-e)%2==0:
      x,y=(d+e)//2,(d-e)//2
      if 0<=x<H and 0<=y<W:
        f=1
      else:
        ans=max(ans,D[d]+E[e])
  for h in range(H):
    if 0<=d-h<W:
        f=1
    else:
      ans=max(ans,D[d]+B[h])
  for w in range(W):
    if 0<=d-w<H:
        f=1
    else:
      ans=max(ans,D[d]+C[w])


for e in E:
  for h in range(H):
    if 0<=h-e<W:
        f=1
    else:
      ans=max(ans,E[e]+B[h])
  for w in range(W):
    if 0<=e+w<H:
        f=1
    else:
      ans=max(ans,E[e]+C[w])

for h in range(H):
  for w in range(W):
    a=A[h][w]
    CC=[B[h],C[w],D[h+w],E[h-w]]
    CC=sorted(CC)[::-1]
    ans=max(ans,CC[0]+CC[1]-a)
print(ans)
0