Skip to content

Commit 319b81b

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents edd4cc8 + 45c8eeb commit 319b81b

5 files changed

Lines changed: 73 additions & 0 deletions

File tree

live12/test121/문제2/백한결.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@ def main():
88

99
result = 0
1010

11+
for i in range(N):
12+
visible = 0
13+
14+
minSlope = float('inf')
15+
for j in range(i-1, -1, -1):
16+
slope = (heights[i] - heights[j]) / (i - j)
17+
if slope < minSlope:
18+
minSlope = slope
19+
visible += 1
20+
21+
maxSlope = -float('inf')
22+
for j in range(i+1, N):
23+
slope = (heights[j] - heights[i]) / (j - i)
24+
if slope > maxSlope:
25+
maxSlope = slope
26+
visible += 1
27+
28+
result = max(result, visible)
29+
30+
print(result)
1131

1232
if __name__ == '__main__':
1333
main()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
3+
def main():
4+
input = sys.stdin.readline
5+
6+
N = int(input())
7+
K = int(input())
8+
9+
sensors = list(map(int, input().split()))
10+
11+
if K >= N:
12+
print(0)
13+
return
14+
15+
sensors.sort()
16+
17+
diffs = []
18+
for i in range(N-1):
19+
diff = sensors[i+1] - sensors[i]
20+
diffs.append(diff)
21+
22+
diffs.sort(reverse=True)
23+
24+
result = sum(diffs[K-1:])
25+
26+
print(result)
27+
28+
if __name__ == '__main__':
29+
main()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sys
2+
3+
def main():
4+
input = sys.stdin.readline
5+
6+
N, M = map(int, input().split())
7+
A = [list(map(int, input().split())) for _ in range(N)]
8+
9+
S = [[0] * (M+1) for _ in range(N+1)]
10+
11+
for i in range(1, N+1):
12+
for j in range(1, M+1):
13+
S[i][j] = A[i-1][j-1] + S[i-1][j] + S[i][j-1] - S[i-1][j-1]
14+
15+
K = int(input())
16+
17+
for _ in range(K):
18+
x1, y1, x2, y2 = map(int, input().split())
19+
result = (S[x2][y2] - S[x1-1][y2] - S[x2][y1-1] + S[x1-1][y1-1])
20+
21+
print(result)
22+
23+
if __name__ == '__main__':
24+
main()

live12/test123/문제1/.gitkeep

Whitespace-only changes.

live12/test123/문제2/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)