Skip to content

Commit 6c51825

Browse files
author
hangyeol
committed
121차 2번 문제풀이
1 parent a9adb22 commit 6c51825

1 file changed

Lines changed: 20 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()

0 commit comments

Comments
 (0)