結果

問題 No.2509 Beam Shateki
ユーザー 👑 timitimi
提出日時 2023-10-27 16:59:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 996 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 76,516 KB
最終ジャッジ日時 2023-10-27 16:59:23
合計ジャッジ時間 5,375 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
53,636 KB
testcase_01 AC 32 ms
53,636 KB
testcase_02 AC 31 ms
53,636 KB
testcase_03 AC 56 ms
70,924 KB
testcase_04 AC 57 ms
70,924 KB
testcase_05 AC 52 ms
70,924 KB
testcase_06 AC 52 ms
70,924 KB
testcase_07 AC 54 ms
70,924 KB
testcase_08 AC 54 ms
70,924 KB
testcase_09 AC 60 ms
70,924 KB
testcase_10 AC 55 ms
70,924 KB
testcase_11 AC 52 ms
70,924 KB
testcase_12 AC 52 ms
70,924 KB
testcase_13 AC 70 ms
76,256 KB
testcase_14 AC 63 ms
76,256 KB
testcase_15 AC 63 ms
76,256 KB
testcase_16 AC 62 ms
76,256 KB
testcase_17 AC 63 ms
76,256 KB
testcase_18 AC 63 ms
76,256 KB
testcase_19 AC 63 ms
76,256 KB
testcase_20 AC 62 ms
76,256 KB
testcase_21 AC 64 ms
76,256 KB
testcase_22 AC 63 ms
76,256 KB
testcase_23 AC 62 ms
76,256 KB
testcase_24 AC 63 ms
76,256 KB
testcase_25 AC 62 ms
76,256 KB
testcase_26 AC 63 ms
76,256 KB
testcase_27 AC 62 ms
76,256 KB
testcase_28 AC 63 ms
76,256 KB
testcase_29 AC 70 ms
76,256 KB
testcase_30 AC 63 ms
76,256 KB
testcase_31 AC 70 ms
76,256 KB
testcase_32 AC 63 ms
76,256 KB
testcase_33 AC 39 ms
61,772 KB
testcase_34 AC 56 ms
70,936 KB
testcase_35 AC 56 ms
73,208 KB
testcase_36 AC 50 ms
68,848 KB
testcase_37 AC 38 ms
62,124 KB
testcase_38 AC 50 ms
68,844 KB
testcase_39 AC 57 ms
73,852 KB
testcase_40 AC 65 ms
76,516 KB
testcase_41 AC 31 ms
53,636 KB
testcase_42 AC 50 ms
68,848 KB
testcase_43 AC 58 ms
74,636 KB
testcase_44 AC 57 ms
74,504 KB
testcase_45 AC 58 ms
68,872 KB
testcase_46 AC 53 ms
70,932 KB
testcase_47 AC 60 ms
73,728 KB
testcase_48 AC 54 ms
70,928 KB
testcase_49 AC 53 ms
70,924 KB
testcase_50 AC 62 ms
72,972 KB
testcase_51 AC 39 ms
61,932 KB
testcase_52 AC 55 ms
73,516 KB
testcase_53 AC 30 ms
53,636 KB
testcase_54 AC 30 ms
53,636 KB
testcase_55 AC 29 ms
53,636 KB
testcase_56 AC 31 ms
53,636 KB
testcase_57 AC 30 ms
53,636 KB
testcase_58 AC 29 ms
53,636 KB
testcase_59 WA -
testcase_60 AC 29 ms
53,636 KB
testcase_61 WA -
testcase_62 WA -
testcase_63 AC 33 ms
53,636 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):
  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