結果
問題 | No.2509 Beam Shateki |
ユーザー | なえしら |
提出日時 | 2024-06-11 22:47:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,573 bytes |
コンパイル時間 | 574 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 79,172 KB |
最終ジャッジ日時 | 2024-06-11 22:47:57 |
合計ジャッジ時間 | 10,005 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,720 KB |
testcase_01 | AC | 33 ms
52,352 KB |
testcase_02 | AC | 33 ms
52,352 KB |
testcase_03 | AC | 130 ms
78,412 KB |
testcase_04 | AC | 135 ms
78,136 KB |
testcase_05 | AC | 131 ms
78,212 KB |
testcase_06 | AC | 144 ms
77,948 KB |
testcase_07 | AC | 136 ms
78,200 KB |
testcase_08 | AC | 158 ms
77,988 KB |
testcase_09 | AC | 132 ms
77,932 KB |
testcase_10 | AC | 145 ms
78,200 KB |
testcase_11 | AC | 131 ms
78,136 KB |
testcase_12 | AC | 128 ms
77,748 KB |
testcase_13 | AC | 155 ms
78,376 KB |
testcase_14 | AC | 159 ms
78,628 KB |
testcase_15 | AC | 152 ms
78,500 KB |
testcase_16 | AC | 207 ms
79,020 KB |
testcase_17 | AC | 151 ms
78,520 KB |
testcase_18 | AC | 152 ms
78,364 KB |
testcase_19 | AC | 156 ms
78,496 KB |
testcase_20 | AC | 191 ms
78,760 KB |
testcase_21 | AC | 182 ms
79,132 KB |
testcase_22 | AC | 150 ms
78,240 KB |
testcase_23 | AC | 173 ms
78,252 KB |
testcase_24 | AC | 149 ms
78,500 KB |
testcase_25 | AC | 151 ms
78,884 KB |
testcase_26 | AC | 189 ms
79,136 KB |
testcase_27 | AC | 177 ms
78,912 KB |
testcase_28 | AC | 149 ms
78,120 KB |
testcase_29 | AC | 149 ms
78,516 KB |
testcase_30 | AC | 181 ms
78,492 KB |
testcase_31 | AC | 198 ms
79,172 KB |
testcase_32 | AC | 151 ms
78,476 KB |
testcase_33 | AC | 87 ms
76,080 KB |
testcase_34 | AC | 135 ms
78,120 KB |
testcase_35 | AC | 149 ms
78,880 KB |
testcase_36 | AC | 134 ms
77,836 KB |
testcase_37 | AC | 104 ms
77,152 KB |
testcase_38 | AC | 150 ms
78,160 KB |
testcase_39 | AC | 130 ms
77,588 KB |
testcase_40 | AC | 138 ms
78,000 KB |
testcase_41 | AC | 47 ms
65,664 KB |
testcase_42 | AC | 133 ms
77,540 KB |
testcase_43 | AC | 147 ms
78,084 KB |
testcase_44 | AC | 155 ms
78,268 KB |
testcase_45 | AC | 124 ms
77,192 KB |
testcase_46 | AC | 157 ms
78,316 KB |
testcase_47 | AC | 174 ms
78,544 KB |
testcase_48 | AC | 135 ms
78,328 KB |
testcase_49 | AC | 145 ms
78,428 KB |
testcase_50 | AC | 158 ms
78,080 KB |
testcase_51 | AC | 95 ms
76,468 KB |
testcase_52 | AC | 142 ms
78,380 KB |
testcase_53 | AC | 35 ms
52,608 KB |
testcase_54 | AC | 33 ms
52,480 KB |
testcase_55 | AC | 34 ms
53,120 KB |
testcase_56 | AC | 34 ms
53,248 KB |
testcase_57 | AC | 35 ms
52,864 KB |
testcase_58 | AC | 33 ms
53,120 KB |
testcase_59 | AC | 33 ms
53,120 KB |
testcase_60 | AC | 33 ms
53,248 KB |
testcase_61 | AC | 33 ms
53,120 KB |
testcase_62 | WA | - |
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]) print(ans)