Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'''
Time Limit Exceeded
53 / 370 testcases passed
'''
class Solution:
def maxValue(self, n: int, index: int, maxSum: int) -> int:
x=1
cap_left = index
cap_right = n-index-1
left = 0
right = 0
left_sum = 0
right_sum = 0
_sum = 0
while True:
# print(x,left,right, left_sum, right_sum, _sum)
if x >=3 and cap_left > left:
left += 1
if x >=3 and cap_right > right:
right += 1
left_sum += left
right_sum += right
_sum = left_sum + right_sum + n + x - 1
x+=1
if _sum > maxSum:
break

return x -2



Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'''
1. 아이디어 :
원과 가까운지 체크

2. 시간복잡도 :
o(n*m) (정렬)

3. 자료구조/알고리즘 :
'''

class Solution:
def countPoints(self, points: list[list[int]], queries: list[list[int]]) -> list[int]:
lst = []
for x1,y1,r in queries:
tmp = 0
for x2,y2 in points:
if (x2 - x1)**2 + (y2 - y1)**2 <= r**2:
# print(x1,y1,x2,y2,r,(x2 - x1)^2 + (y2 - y1)^2)
tmp += 1
lst.append(tmp)
return lst