結果
問題 |
No.2509 Beam Shateki
|
ユーザー |
![]() |
提出日時 | 2023-10-27 16:59:17 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 996 bytes |
コンパイル時間 | 235 ms |
コンパイル使用メモリ | 82,508 KB |
実行使用メモリ | 76,916 KB |
最終ジャッジ日時 | 2024-09-25 13:04:54 |
合計ジャッジ時間 | 5,863 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 58 WA * 3 |
ソースコード
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)