結果
問題 | No.2509 Beam Shateki |
ユーザー | なえしら |
提出日時 | 2024-06-11 23:04:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,978 bytes |
コンパイル時間 | 367 ms |
コンパイル使用メモリ | 81,772 KB |
実行使用メモリ | 79,272 KB |
最終ジャッジ日時 | 2024-06-11 23:05:08 |
合計ジャッジ時間 | 10,413 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
53,628 KB |
testcase_01 | AC | 37 ms
53,284 KB |
testcase_02 | AC | 36 ms
52,808 KB |
testcase_03 | AC | 141 ms
77,580 KB |
testcase_04 | AC | 148 ms
77,708 KB |
testcase_05 | AC | 164 ms
77,836 KB |
testcase_06 | AC | 138 ms
78,208 KB |
testcase_07 | AC | 141 ms
78,436 KB |
testcase_08 | AC | 141 ms
78,088 KB |
testcase_09 | AC | 139 ms
78,184 KB |
testcase_10 | AC | 158 ms
77,816 KB |
testcase_11 | AC | 154 ms
78,080 KB |
testcase_12 | AC | 140 ms
78,196 KB |
testcase_13 | AC | 175 ms
78,752 KB |
testcase_14 | AC | 159 ms
78,112 KB |
testcase_15 | AC | 164 ms
78,368 KB |
testcase_16 | AC | 195 ms
79,264 KB |
testcase_17 | AC | 157 ms
78,112 KB |
testcase_18 | AC | 155 ms
78,116 KB |
testcase_19 | AC | 160 ms
78,112 KB |
testcase_20 | AC | 219 ms
78,632 KB |
testcase_21 | AC | 188 ms
78,624 KB |
testcase_22 | AC | 159 ms
78,116 KB |
testcase_23 | AC | 158 ms
78,200 KB |
testcase_24 | AC | 159 ms
78,432 KB |
testcase_25 | AC | 162 ms
78,504 KB |
testcase_26 | AC | 210 ms
79,272 KB |
testcase_27 | AC | 209 ms
78,880 KB |
testcase_28 | AC | 163 ms
78,116 KB |
testcase_29 | AC | 164 ms
78,372 KB |
testcase_30 | AC | 158 ms
78,364 KB |
testcase_31 | AC | 210 ms
78,904 KB |
testcase_32 | AC | 161 ms
78,376 KB |
testcase_33 | AC | 92 ms
76,496 KB |
testcase_34 | AC | 159 ms
77,732 KB |
testcase_35 | AC | 160 ms
78,232 KB |
testcase_36 | AC | 145 ms
78,028 KB |
testcase_37 | AC | 115 ms
76,844 KB |
testcase_38 | AC | 142 ms
78,052 KB |
testcase_39 | AC | 140 ms
78,440 KB |
testcase_40 | AC | 147 ms
78,724 KB |
testcase_41 | AC | 51 ms
66,892 KB |
testcase_42 | AC | 142 ms
78,088 KB |
testcase_43 | AC | 174 ms
78,720 KB |
testcase_44 | AC | 161 ms
78,516 KB |
testcase_45 | AC | 133 ms
77,520 KB |
testcase_46 | AC | 155 ms
77,868 KB |
testcase_47 | AC | 165 ms
78,552 KB |
testcase_48 | AC | 150 ms
77,752 KB |
testcase_49 | AC | 159 ms
78,244 KB |
testcase_50 | AC | 169 ms
77,996 KB |
testcase_51 | AC | 101 ms
76,584 KB |
testcase_52 | AC | 147 ms
77,820 KB |
testcase_53 | AC | 36 ms
53,796 KB |
testcase_54 | AC | 36 ms
53,884 KB |
testcase_55 | AC | 36 ms
54,056 KB |
testcase_56 | AC | 36 ms
53,516 KB |
testcase_57 | AC | 35 ms
54,424 KB |
testcase_58 | AC | 35 ms
53,808 KB |
testcase_59 | AC | 37 ms
54,536 KB |
testcase_60 | AC | 36 ms
53,836 KB |
testcase_61 | AC | 36 ms
53,964 KB |
testcase_62 | AC | 36 ms
52,824 KB |
testcase_63 | WA | - |
ソースコード
class Max2: def __init__(self, fst_key=-1, fst_val=-9*10**18, snd_key=-2, snd_val=-9*10**18): self.fst_key, self.fst_val = fst_key, fst_val self.snd_key, self.snd_val = snd_key, snd_val def chmax2(self, key, val): if key == self.fst_key: self.fst_val = max(self.fst_val, val) elif val > self.fst_val: self.snd_key, self.snd_val = self.fst_key, self.fst_val self.fst_key, self.fst_val = key, val elif val > self.snd_val: self.snd_key, self.snd_val = key, val from itertools import product H, W = map(int, input().split()) A = [[0]*(2*H+W) for _ in range(2*W+H)] for i in range(H): A[W+i][H:H+W] = list(map(int, input().split())) row, col = [0]*(2*W+H), [0]*(2*H+W) diag, skew = [0]*(3*H+3*W), [0]*(3*H+3*W) for i, j in product(range(2*W+H), range(2*H+W)): row[i] += A[i][j]; col[j] += A[i][j] diag[i-j] += A[i][j]; skew[i+j] += A[i][j] row_max2, col_max2 = Max2(), Max2() diag_max2, skew_max2 = Max2(), Max2() for i in range(2*W+H): row_max2.chmax2(i, row[i]) for j in range(2*H+W): col_max2.chmax2(j, col[j]) for k in range(3*H+3*W): diag_max2.chmax2(k, diag[k]) for l in range(3*H+3*W): skew_max2.chmax2(l, skew[l]) ans = max( row_max2.fst_val + row_max2.snd_val, col_max2.fst_val + col_max2.snd_val, diag_max2.fst_val + diag_max2.snd_val, skew_max2.fst_val + skew_max2.snd_val ) for i, j in product(range(2*W+H), range(2*H+W)): max2 = Max2(0, row[i]); max2.chmax2(1, col[j]) max2.chmax2(2, diag[i-j]); max2.chmax2(2, skew[i+j]) ans = max(ans, max2.fst_val + max2.snd_val - A[i][j]) even_diag_max = odd_diag_max = 0 even_skew_max = odd_skew_max = 0 for k in range(3*H+3*W): if k%2: odd_diag_max = max(odd_diag_max, diag[k]) else: even_diag_max = max(even_diag_max, diag[k]) for l in range(3*H+3*W): if l%2: odd_skew_max = max(odd_skew_max, skew[l]) else: even_skew_max = max(even_skew_max, skew[l]) ans = max(ans, even_diag_max + odd_skew_max, even_skew_max + odd_diag_max ) print(ans)