Skip to content

Commit edd4cc8

Browse files
committed
122차 문제 순서 변경
1 parent ab8502b commit edd4cc8

1 file changed

Lines changed: 25 additions & 14 deletions

File tree

live12/test122/문제2/박희경.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,30 @@
22

33
input = sys.stdin.readline
44

5-
n = int(input())
5+
n, m = map(int, input().split())
6+
area = []
7+
for _ in range(n):
8+
area.append(list(map(int, input().split())))
9+
10+
prefix_sum = [[0] * (m + 1) for _ in range(n + 1)]
11+
for i in range(1, n + 1):
12+
for j in range(1, m + 1):
13+
prefix_sum[i][j] = prefix_sum[i-1][j] + prefix_sum[i][j-1] - prefix_sum[i-1][j-1] + area[i-1][j-1]
14+
615
k = int(input())
7-
sensor = list(map(int, input().split()))
8-
sensor.sort()
16+
for _ in range(k):
17+
x1, y1, x2, y2 = map(int, input().split())
18+
result = prefix_sum[x2][y2] - prefix_sum[x1 - 1][y2] - prefix_sum[x2][y1 - 1] + prefix_sum[x1-1][y1-1]
19+
print(result)
920

10-
res, cnt = 0, 1
11-
for i in range(n):
12-
if i % 2 != 0:
13-
if i == n - 1: abs(sensor[i] - sensor[i-1])
14-
else:
15-
res += min(abs(sensor[i] - sensor[i-1]), abs(sensor[i+1] - sensor[i]))
16-
else:
17-
if cnt < k:
18-
cnt += 1
19-
20-
print(res)
21+
"""
22+
4 4
23+
9 14 29 7
24+
1 31 6 13
25+
21 26 40 16
26+
8 38 11 23
27+
3
28+
1 1 3 2
29+
1 1 1 4
30+
1 1 4 4
31+
"""

0 commit comments

Comments
 (0)