using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
public static void Main()
var result = new Ray().solution(new Point2D[]{new Point2D{x = -1, y = -2}, new Point2D{x = 1, y = 2}, new Point2D{x = 2, y = 4}, });
Console.WriteLine(result);
public int solution(Point2D[] A)
var sortedPointsFirstAndSecondSector = new SortedList<Point2D, Point2D>(new PointCompararer());
var sortedPointsThirdAndForthSector = new SortedList<Point2D, Point2D>(new PointCompararer());
var isOxPositiveIncluded = false;
var isOxNegativeIncluded = false;
isOxPositiveIncluded = true;
isOxNegativeIncluded = true;
if (sortedPointsFirstAndSecondSector.ContainsKey(point))
sortedPointsFirstAndSecondSector.Add(point, point);
if (sortedPointsThirdAndForthSector.ContainsKey(point))
sortedPointsThirdAndForthSector.Add(point, point);
return sortedPointsFirstAndSecondSector.Keys.Count + sortedPointsThirdAndForthSector.Keys.Count + (isOxPositiveIncluded ? 1 : 0) + (isOxNegativeIncluded ? 1 : 0);
public class PointCompararer : IComparer<Point2D>
public int Compare([AllowNull] Point2D first, [AllowNull] Point2D second)
return first.x * second.y == first.y * second.x ? 0 : first.x * second.y > first.y * second.x ? -1 : 0;