Minimum radius
Practice
3.7 (6 votes)
Binary search
Algorithms
C++
Problem
69% Success 3201 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given two arrays X and Y of N elements denoting N points on the 2D plane. You are given another array A of N elements denoting the values associated with each point.
You have to find the minimum integer value radius r of a circle with the center (0,0) such that the sum of all the values of nodes within the circle or on the circle is greater than or equal to an integer p.
If any such r does not exist, print -1.
Notes
- Assume 1-based indexing.
- For a circle with radius 0, the center is said to lie inside that circle.
Input
- The first line contains an integer T denoting the number of test cases.
- For each test case:
- The first line contains two space-separated integers N, p.
- The second line contains N space-separated integers denoting the array X.
- The third line contains N space-separated integers denoting the array Y.
- The fourth line contains N space-separated integers denoting the array A.
Output
For each test case in a new line, print the minimum integer value radius r of the required circle.
Constraints
\(1 ≤ T ≤ 10\\ 1 ≤ N ≤ 10^5\\ 0 ≤ p ≤ 10^9\\ - 10^8 ≤ X[i], Y[i] ≤ 10^8\\ 0 ≤ A[i] ≤ 10^4\\\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
54 votes
Tags:
AlgorithmsBinary SearchC++
Points:30
14 votes
Tags:
AlgorithmsApprovedBinary SearchEasyOpenSorting
Points:30
29 votes
Tags:
C++Basic ProgrammingBit ManipulationBasics of Bit ManipulationAlgorithmsBinary Search
Editorial