結果

問題 No.2509 Beam Shateki
ユーザー rlangevinrlangevin
提出日時 2023-12-31 01:16:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,288 ms / 2,000 ms
コード長 1,559 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,332 KB
最終ジャッジ日時 2023-12-31 01:17:15
合計ジャッジ時間 39,169 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 283 ms
77,260 KB
testcase_04 AC 281 ms
77,260 KB
testcase_05 AC 278 ms
77,256 KB
testcase_06 AC 286 ms
77,260 KB
testcase_07 AC 279 ms
77,260 KB
testcase_08 AC 279 ms
77,260 KB
testcase_09 AC 279 ms
77,256 KB
testcase_10 AC 302 ms
77,260 KB
testcase_11 AC 286 ms
77,256 KB
testcase_12 AC 276 ms
77,260 KB
testcase_13 AC 1,269 ms
77,948 KB
testcase_14 AC 1,288 ms
77,948 KB
testcase_15 AC 1,259 ms
78,204 KB
testcase_16 AC 1,254 ms
78,332 KB
testcase_17 AC 1,263 ms
78,332 KB
testcase_18 AC 1,276 ms
78,076 KB
testcase_19 AC 1,266 ms
78,332 KB
testcase_20 AC 1,256 ms
78,204 KB
testcase_21 AC 1,258 ms
78,332 KB
testcase_22 AC 1,269 ms
78,076 KB
testcase_23 AC 1,254 ms
77,948 KB
testcase_24 AC 1,254 ms
78,204 KB
testcase_25 AC 1,267 ms
78,076 KB
testcase_26 AC 1,262 ms
78,204 KB
testcase_27 AC 1,256 ms
78,204 KB
testcase_28 AC 1,264 ms
78,204 KB
testcase_29 AC 1,261 ms
78,204 KB
testcase_30 AC 1,262 ms
78,204 KB
testcase_31 AC 1,265 ms
78,204 KB
testcase_32 AC 1,273 ms
78,076 KB
testcase_33 AC 158 ms
76,468 KB
testcase_34 AC 387 ms
77,040 KB
testcase_35 AC 671 ms
77,488 KB
testcase_36 AC 233 ms
77,044 KB
testcase_37 AC 84 ms
75,708 KB
testcase_38 AC 251 ms
77,152 KB
testcase_39 AC 234 ms
77,076 KB
testcase_40 AC 440 ms
77,176 KB
testcase_41 AC 85 ms
75,860 KB
testcase_42 AC 286 ms
77,208 KB
testcase_43 AC 793 ms
77,532 KB
testcase_44 AC 919 ms
77,600 KB
testcase_45 AC 237 ms
77,048 KB
testcase_46 AC 343 ms
77,212 KB
testcase_47 AC 921 ms
77,488 KB
testcase_48 AC 375 ms
77,192 KB
testcase_49 AC 492 ms
76,988 KB
testcase_50 AC 580 ms
77,400 KB
testcase_51 AC 124 ms
76,060 KB
testcase_52 AC 405 ms
77,060 KB
testcase_53 AC 43 ms
59,580 KB
testcase_54 AC 44 ms
59,580 KB
testcase_55 AC 47 ms
61,960 KB
testcase_56 AC 47 ms
61,960 KB
testcase_57 AC 48 ms
61,960 KB
testcase_58 AC 47 ms
61,960 KB
testcase_59 AC 47 ms
61,960 KB
testcase_60 AC 47 ms
61,960 KB
testcase_61 AC 47 ms
61,960 KB
testcase_62 AC 73 ms
61,960 KB
testcase_63 AC 47 ms
61,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
A = []
for i in range(H):
    A.append(list(map(int, input().split())))
    
L = []
for i in range(H):
    for j in range(W):
        if i == 0 or j == W - 1 or j == 0:
            L.append((i, j))
            
dx = [1, 0, 1, 1]
dy = [0, 1, 1, -1]

def f(x1, y1, k1, x2, y2, k2):
    S = set()
    while True:
        S.add(x1*W+y1)
        x1 += dx[k1]
        y1 += dy[k1]
        if x1 < 0 or x1 > H - 1 or y1 < 0 or y1 > W - 1:
            break
    while True:
        S.add(x2*W+y2)
        x2 += dx[k2]
        y2 += dy[k2]
        if x2 < 0 or x2 > H - 1 or y2 < 0 or y2 > W - 1:
            break
    return S

ans = 0
for a in range(len(L)):
    x1, y1 = L[a]
    for k1 in range(4):
        if k1 == 0 and x1 != 0:
            continue
        if k1 == 1 and y1 != 0:
            continue
        if k1 == 2 and y1 == W - 1:
            continue
        if k1 == 3 and y1 == 0:
            continue
        for b in range(a, len(L)):
            x2, y2 = L[b]
            for k2 in range(4):
                if k2 == 0 and x2 != 0:
                    continue
                if k2 == 1 and y2 != 0:
                    continue
                if k2 == 2 and y2 == W - 1:
                    continue
                if k2 == 3 and y2 == 0:
                    continue
                S = f(x1, y1, k1, x2, y2, k2)
                temp = 0
                for v in S:
                    xs, ys = divmod(v, W)
                    temp += A[xs][ys]
                ans = max(ans, temp)
                
print(ans)
0