結果
問題 | No.2509 Beam Shateki |
ユーザー | ntuda |
提出日時 | 2023-12-14 19:36:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 98 ms / 2,000 ms |
コード長 | 2,251 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 82,388 KB |
実行使用メモリ | 77,104 KB |
最終ジャッジ日時 | 2024-09-27 05:46:01 |
合計ジャッジ時間 | 6,171 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
52,480 KB |
testcase_01 | AC | 33 ms
52,480 KB |
testcase_02 | AC | 30 ms
51,840 KB |
testcase_03 | AC | 78 ms
76,380 KB |
testcase_04 | AC | 80 ms
76,784 KB |
testcase_05 | AC | 79 ms
76,544 KB |
testcase_06 | AC | 78 ms
76,476 KB |
testcase_07 | AC | 94 ms
76,652 KB |
testcase_08 | AC | 78 ms
76,544 KB |
testcase_09 | AC | 80 ms
76,476 KB |
testcase_10 | AC | 87 ms
76,860 KB |
testcase_11 | AC | 82 ms
76,476 KB |
testcase_12 | AC | 79 ms
76,424 KB |
testcase_13 | AC | 92 ms
76,584 KB |
testcase_14 | AC | 87 ms
76,640 KB |
testcase_15 | AC | 90 ms
76,636 KB |
testcase_16 | AC | 89 ms
76,808 KB |
testcase_17 | AC | 89 ms
76,640 KB |
testcase_18 | AC | 89 ms
76,692 KB |
testcase_19 | AC | 89 ms
76,516 KB |
testcase_20 | AC | 90 ms
76,676 KB |
testcase_21 | AC | 94 ms
76,876 KB |
testcase_22 | AC | 94 ms
76,392 KB |
testcase_23 | AC | 91 ms
76,900 KB |
testcase_24 | AC | 88 ms
76,700 KB |
testcase_25 | AC | 88 ms
76,964 KB |
testcase_26 | AC | 93 ms
76,520 KB |
testcase_27 | AC | 89 ms
76,700 KB |
testcase_28 | AC | 90 ms
76,616 KB |
testcase_29 | AC | 88 ms
76,512 KB |
testcase_30 | AC | 89 ms
76,684 KB |
testcase_31 | AC | 98 ms
76,956 KB |
testcase_32 | AC | 90 ms
76,716 KB |
testcase_33 | AC | 60 ms
71,808 KB |
testcase_34 | AC | 83 ms
76,776 KB |
testcase_35 | AC | 86 ms
76,924 KB |
testcase_36 | AC | 73 ms
76,800 KB |
testcase_37 | AC | 48 ms
65,664 KB |
testcase_38 | AC | 81 ms
76,552 KB |
testcase_39 | AC | 74 ms
76,160 KB |
testcase_40 | AC | 81 ms
76,544 KB |
testcase_41 | AC | 44 ms
63,488 KB |
testcase_42 | AC | 80 ms
76,648 KB |
testcase_43 | AC | 88 ms
76,548 KB |
testcase_44 | AC | 91 ms
77,104 KB |
testcase_45 | AC | 71 ms
76,544 KB |
testcase_46 | AC | 73 ms
76,672 KB |
testcase_47 | AC | 87 ms
76,600 KB |
testcase_48 | AC | 82 ms
76,700 KB |
testcase_49 | AC | 83 ms
76,524 KB |
testcase_50 | AC | 84 ms
76,416 KB |
testcase_51 | AC | 57 ms
69,760 KB |
testcase_52 | AC | 79 ms
76,568 KB |
testcase_53 | AC | 35 ms
52,736 KB |
testcase_54 | AC | 34 ms
52,736 KB |
testcase_55 | AC | 32 ms
52,864 KB |
testcase_56 | AC | 32 ms
53,248 KB |
testcase_57 | AC | 32 ms
53,248 KB |
testcase_58 | AC | 32 ms
52,892 KB |
testcase_59 | AC | 33 ms
52,480 KB |
testcase_60 | AC | 34 ms
52,736 KB |
testcase_61 | AC | 34 ms
53,248 KB |
testcase_62 | AC | 34 ms
52,864 KB |
testcase_63 | AC | 33 ms
52,864 KB |
ソースコード
H, W = map(int, input().split()) W = 2 * H + W - 2 A = [[0] * (H - 1) + list(map(int, input().split())) + [0] * (H - 1) for _ in range(H)] N = W * 3 + H D = [(1, -1), (1, 0), (1, 1), (0, 1)] S = [0] * N for i in range(N): if i < W * 3: y = i // 3 x = 0 d = i % 3 else: y = 0 x = i - W * 3 d = 3 tmp = 0 while 0 <= x < H and 0 <= y < W: tmp += A[x][y] x += D[d][0] y += D[d][1] S[i] = tmp #for i in range(H): #print(*A[i]) #print(S) ans = 0 for i in range(N - 1): if i < W * 3: y1 = i // 3 x1 = 0 d1 = i % 3 else: y1 = 0 x1 = i - W * 3 d1 = 3 for j in range(i + 1, N): tmp = S[i] + S[j] if j < W * 3: y2 = j // 3 x2 = 0 d2 = j % 3 else: x2 = j - W * 3 y2 = 0 d2 = 3 if d2 == 3: if d1 == 0: if 0 <= y1 - x2 < W: tmp -= A[x2][y1 - x2] elif d1 == 1: tmp -= A[x2][y1] elif d1 == 2: if 0 <= y1 + x2 < W: tmp -= A[x2][y1 + x2] ans = max(ans, tmp) #print(i,j,":","a",x1,y1,d1,x2,y2,d2,":",S[i]+S[j],tmp) continue if y1 == y2: tmp -= A[0][y1] #print(i,j,":","b",x1,y1,d1,x2,y2,d2,":",S[i]+S[j],tmp) ans = max(ans, tmp) continue if d2 == 0: if d1 == 2: yt = y2 - y1 if yt % 2 == 0 and yt // 2 < H: tmp -= A[yt // 2][(y2 + y1) // 2] elif d1 == 1: if y2 - y1 < H: tmp -= A[y2 - y1][y1] #print(i,j,":","c",x1,y1,d1,x2,y2,d2,":",S[i]+S[j],tmp) ans = max(ans, tmp) continue if d2 == 1 and d1 == 2: if y2 - y1 < H: tmp -= A[y2 - y1][y2] #print(i, j, ":","d", x1, y1, d1, x2, y2, d2, ":", S[i] + S[j], tmp) ans = max(ans, tmp) continue #print(i, j, ":","e", x1, y1, d1, x2, y2, d2, ":", S[i] + S[j], tmp) ans = max(ans, tmp) print(ans)