Beispiel #1
0
    static void Main(String[] args)
    {
        var s = new SortedSet <int>();
        int n = Cin.NextInt();

        for (int i = 0; i < n; i++)
        {
            int c = Cin.NextInt();
            if (c == 3)
            {
                Cout.Print(s.Min);
            }
            else
            {
                int oph = Cin.NextInt();
                if (c == 1)
                {
                    s.Add(oph);
                }
                else
                {
                    s.Remove(oph);
                }
            }
        }
    }
Beispiel #2
0
    static void Main(String[] args)
    {
        int n = Cin.NextInt();
        int k = Cin.NextInt();

        int[] ns = new int[n];
        var   d  = new Dictionary <int, int>();

        for (int i = 0; i < n; i++)
        {
            ns[i] = Cin.NextInt();
            int r = ns[i] % k;
            if (!d.ContainsKey(r))
            {
                d[r] = 0;
            }
            d[r]++;
        }

        int ans = 0;

        for (int i = 1; i < (k + 1) / 2; i++)
        {
            int a     = i;
            int b     = k - i;
            int cnt_a = d.ContainsKey(a)? d[a]: 0;
            int cnt_b = d.ContainsKey(b)? d[b]: 0;

            // Cout.Print($"{a} {b} {cnt_a} {cnt_b}");

            ans += Math.Max(cnt_a, cnt_b);
        }

        if (d.ContainsKey(0))
        {
            ans++;
        }

        if (k % 2 == 0 && d.ContainsKey(k / 2))
        {
            ans++;
        }
        Cout.Print(ans);
    }
Beispiel #3
0
        static void Main(string[] args)
        {
            int n = Cin.NextInt();

            string[] maze = new string[n];
            for (int i = 0; i < n; i++)
            {
                maze[i] = Cin.NextToken();
            }

            int y1 = Cin.NextInt();
            int x1 = Cin.NextInt();
            int y2 = Cin.NextInt();
            int x2 = Cin.NextInt();

            var p1 = new Point(x1, y1);
            var p2 = new Point(x2, y2);

            Cout.Print(Bfs(maze, n, p1, p2));
        }
Beispiel #4
0
        public void Resolve()
        {
            var cursorVisible = Console.CursorVisible;

            Console.CursorVisible = true;

            while (true)
            {
                Cout.Print("? ", new ConColor {
                    ForegroundColor = ConsoleColor.Green
                });
                Cout.Print($"{Question}: ");

                var left = Console.CursorLeft;
                var top  = Console.CursorTop;

                var answer = Console.ReadLine();
                var result = Resolver(answer);

                if (result is null)
                {
                    continue;
                }

                Console.SetCursorPosition(left, top);
                Echo.Instance.Print(result, new ConColor {
                    ForegroundColor = ConsoleColor.Cyan
                });
                if (result.GetLengthA() < answer.GetLengthA())
                {
                    Console.Write(" ".Repeat(answer.GetLengthA() - result.GetLengthA()));
                }
                Console.WriteLine();

                break;
            }

            Console.CursorVisible = cursorVisible;
        }
Beispiel #5
0
        public void Resolve(Action <AskAnswer> resolve)
        {
begin:
            var buffer = new StringBuilder();
            var answer = new AskAnswer();

            if (Question is not null && Question.Length > 0)
            {
                PrintAskHint?.Invoke();
                if (Question.EndsWith(Environment.NewLine))
                {
                    Cout.Print(Question);
                }
                else
                {
                    Cout.Print($"{Question} ");
                }
            }

            var left = Console.CursorLeft;
            var top  = Console.CursorTop;

            while (true)
            {
                answer.Action = AskAction.Default;

                var line = Console.ReadLine();
                buffer.Append(line);
                var bufferString = buffer.ToString();
                answer.Value = bufferString;
                resolve(answer);

                if (answer.Action == AskAction.Default)
                {
                    throw new InvalidOperationException($"AskAnswer.Action must be changed in the method.");
                }

                if (answer.Action == AskAction.Accept)
                {
                    Console.SetCursorPosition(left, top);
                    Echo.Instance.Print(" ".Repeat(bufferString.GetLengthA()));
                    Console.SetCursorPosition(left, top);
                    Echo.Instance.Print(answer.Value, new ConColor {
                        ForegroundColor = ConsoleColor.Cyan
                    });
                    Console.WriteLine();
                    return;
                }
                else if (answer.Action == AskAction.Continue)
                {
                    buffer.AppendLine();
                    continue;
                }
                else if (answer.Action == AskAction.Retry)
                {
                    goto begin;
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }