結果
問題 | No.2509 Beam Shateki |
ユーザー | lloyz |
提出日時 | 2023-12-29 21:16:57 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 134 ms / 2,000 ms |
コード長 | 1,648 bytes |
コンパイル時間 | 1,464 ms |
コンパイル使用メモリ | 82,436 KB |
実行使用メモリ | 78,020 KB |
最終ジャッジ日時 | 2024-09-27 16:21:01 |
合計ジャッジ時間 | 9,187 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
54,388 KB |
testcase_01 | AC | 38 ms
54,572 KB |
testcase_02 | AC | 38 ms
54,692 KB |
testcase_03 | AC | 107 ms
77,772 KB |
testcase_04 | AC | 108 ms
77,888 KB |
testcase_05 | AC | 109 ms
77,768 KB |
testcase_06 | AC | 121 ms
77,956 KB |
testcase_07 | AC | 120 ms
77,632 KB |
testcase_08 | AC | 121 ms
77,828 KB |
testcase_09 | AC | 119 ms
77,648 KB |
testcase_10 | AC | 121 ms
77,636 KB |
testcase_11 | AC | 120 ms
77,660 KB |
testcase_12 | AC | 119 ms
77,696 KB |
testcase_13 | AC | 128 ms
78,012 KB |
testcase_14 | AC | 131 ms
77,816 KB |
testcase_15 | AC | 130 ms
77,820 KB |
testcase_16 | AC | 130 ms
77,944 KB |
testcase_17 | AC | 129 ms
77,680 KB |
testcase_18 | AC | 132 ms
77,816 KB |
testcase_19 | AC | 129 ms
77,688 KB |
testcase_20 | AC | 134 ms
77,808 KB |
testcase_21 | AC | 134 ms
77,820 KB |
testcase_22 | AC | 133 ms
77,684 KB |
testcase_23 | AC | 132 ms
77,896 KB |
testcase_24 | AC | 129 ms
77,900 KB |
testcase_25 | AC | 129 ms
77,764 KB |
testcase_26 | AC | 131 ms
77,908 KB |
testcase_27 | AC | 129 ms
77,812 KB |
testcase_28 | AC | 133 ms
78,020 KB |
testcase_29 | AC | 130 ms
77,928 KB |
testcase_30 | AC | 129 ms
77,852 KB |
testcase_31 | AC | 132 ms
77,900 KB |
testcase_32 | AC | 134 ms
77,884 KB |
testcase_33 | AC | 75 ms
70,912 KB |
testcase_34 | AC | 126 ms
77,844 KB |
testcase_35 | AC | 130 ms
77,864 KB |
testcase_36 | AC | 112 ms
77,148 KB |
testcase_37 | AC | 77 ms
72,320 KB |
testcase_38 | AC | 110 ms
77,108 KB |
testcase_39 | AC | 110 ms
77,092 KB |
testcase_40 | AC | 121 ms
77,828 KB |
testcase_41 | AC | 49 ms
61,312 KB |
testcase_42 | AC | 109 ms
77,132 KB |
testcase_43 | AC | 127 ms
77,808 KB |
testcase_44 | AC | 128 ms
77,768 KB |
testcase_45 | AC | 109 ms
77,044 KB |
testcase_46 | AC | 110 ms
77,288 KB |
testcase_47 | AC | 127 ms
77,736 KB |
testcase_48 | AC | 121 ms
77,948 KB |
testcase_49 | AC | 123 ms
77,736 KB |
testcase_50 | AC | 124 ms
77,932 KB |
testcase_51 | AC | 79 ms
72,960 KB |
testcase_52 | AC | 124 ms
77,656 KB |
testcase_53 | AC | 40 ms
54,400 KB |
testcase_54 | AC | 41 ms
54,016 KB |
testcase_55 | AC | 44 ms
54,508 KB |
testcase_56 | AC | 40 ms
54,016 KB |
testcase_57 | AC | 40 ms
54,272 KB |
testcase_58 | AC | 41 ms
54,272 KB |
testcase_59 | AC | 40 ms
54,528 KB |
testcase_60 | AC | 40 ms
54,272 KB |
testcase_61 | AC | 41 ms
54,184 KB |
testcase_62 | AC | 41 ms
54,144 KB |
testcase_63 | AC | 40 ms
54,016 KB |
ソースコード
from collections import defaultdict h, w = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(h)] T = defaultdict(int) Y = defaultdict(int) P = defaultdict(int) M = defaultdict(int) for i in range(h): for j in range(w): T[i] += A[i][j] Y[j] += A[i][j] P[i + j] += A[i][j] M[i - j] += A[i][j] ans = 0 L = [T, Y, P, M] for C in L: for i in C: for j in C: if i == j: continue ans = max(ans, C[i] + C[j]) for i in T: for j in Y: ans = max(ans, T[i] + Y[j] - A[i][j]) for i in T: for j in P: x = i y = j - i if 0 <= y < w: ans = max(ans, T[i] + P[j] - A[x][y]) else: ans = max(ans, T[i] + P[j]) for i in T: for j in M: x = i y = i - j if 0 <= y < w: ans = max(ans, T[i] + M[j] - A[x][y]) else: ans = max(ans, T[i] + M[j]) for i in Y: for j in P: x = j - i y = i if 0 <= x < h: ans = max(ans, Y[i] + P[j] - A[x][y]) else: ans = max(ans, Y[i] + P[j]) for i in Y: for j in M: x = i + j y = i if 0 <= x < h: ans = max(ans, Y[i] + M[j] - A[x][y]) else: ans = max(ans, Y[i] + M[j]) for i in P: for j in M: x = (i + j) / 2 y = (i - j) / 2 if int(x) == x and int(y) == y and 0 <= x < h and 0 <= y < w: x = int(x) y = int(y) ans = max(ans, P[i] + M[j] - A[x][y]) else: ans = max(ans, P[i] + M[j]) print(ans)