Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve() {
- // Test case #4
- n = 4;
- points = new ArrayList<>(n);
- points.add(new Point(1,-10000000));
- points.add(new Point(1, 10000000));
- points.add(new Point(10000000, -10000000));
- points.add(new Point(10000000, 10000000));
- // This solution incorrectly returns "true"
- double r = 4.985E13;
- double x = 9765.625;
- io.println(acceptable(x,r));
- }
- boolean acceptable(double x, double r) {
- double maxDistLeft = 0;
- double maxDistRight = 0;
- for (Point p : points) {
- double xDist = Math.abs((long)x - (long)p.x);
- double yDist = Math.abs((long)r - (long)p.y);
- double dist = Math.sqrt(xDist) * Math.sqrt(yDist) * Math.sqrt(xDist/yDist + yDist/xDist);
- if (p.x <= x) {
- maxDistLeft = max(maxDistLeft, dist);
- } else {
- maxDistRight = max(maxDistRight, dist);
- }
- }
- return (maxDistLeft <= r && maxDistRight <= r);
- }
Advertisement
Add Comment
Please, Sign In to add comment