Submission #52072763


Source Code Expand

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;

namespace Tasks;

public class C
{
    public static void Main()
    {
        using var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static void Solve()
    {
        var N = Scanner.Scan<int>();
        var dict = new Dictionary<int, int>();
        const int Inf = 1 << 30;
        for (var i = 0; i < N; i++)
        {
            var (a, c) = Scanner.Scan<int, int>();
            if (!dict.ContainsKey(c)) dict[c] = Inf;
            dict[c] = Math.Min(dict[c], a);
        }

        var answer = dict.Values.Max();
        Console.WriteLine(answer);
    }

    public static class Scanner
    {
        public static T Scan<T>() where T : IConvertible => Convert<T>(ScanStringArray()[0]);
        public static (T1, T2) Scan<T1, T2>() where T1 : IConvertible where T2 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]));
        }
        public static (T1, T2, T3) Scan<T1, T2, T3>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]));
        }
        public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]));
        }
        public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[4]));
        }
        public static (T1, T2, T3, T4, T5, T6) Scan<T1, T2, T3, T4, T5, T6>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible where T6 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[4]), Convert<T6>(input[5]));
        }
        public static IEnumerable<T> ScanEnumerable<T>() where T : IConvertible => ScanStringArray().Select(Convert<T>);
        private static string[] ScanStringArray()
        {
            var line = Console.ReadLine()?.Trim() ?? string.Empty;
            return string.IsNullOrEmpty(line) ? Array.Empty<string>() : line.Split(' ');
        }
        private static T Convert<T>(string value) where T : IConvertible => (T)System.Convert.ChangeType(value, typeof(T));
    }
}

Submission Info

Submission Time
Task C - Colorful Beans
User AconCavy
Language C# 11.0 (.NET 7.0.7)
Score 250
Code Size 3173 Byte
Status AC
Exec Time 149 ms
Memory 68356 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 250 / 250
Status
AC × 2
AC × 30
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 02_maximum_00.txt, 02_maximum_01.txt, 02_maximum_02.txt, 02_maximum_03.txt, 02_maximum_04.txt, 02_maximum_05.txt, 02_maximum_06.txt, 02_maximum_07.txt, 02_maximum_08.txt, 02_maximum_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 56 ms 26692 KiB
00_sample_01.txt AC 57 ms 26456 KiB
01_random_00.txt AC 83 ms 39992 KiB
01_random_01.txt AC 69 ms 34524 KiB
01_random_02.txt AC 122 ms 52408 KiB
01_random_03.txt AC 67 ms 35860 KiB
01_random_04.txt AC 126 ms 55084 KiB
01_random_05.txt AC 107 ms 54800 KiB
01_random_06.txt AC 109 ms 54568 KiB
01_random_07.txt AC 109 ms 55508 KiB
01_random_08.txt AC 98 ms 50904 KiB
01_random_09.txt AC 123 ms 55792 KiB
01_random_10.txt AC 68 ms 31104 KiB
01_random_11.txt AC 73 ms 42504 KiB
01_random_12.txt AC 103 ms 55272 KiB
01_random_13.txt AC 105 ms 54620 KiB
01_random_14.txt AC 73 ms 33956 KiB
01_random_15.txt AC 122 ms 55416 KiB
01_random_16.txt AC 70 ms 37764 KiB
01_random_17.txt AC 107 ms 49940 KiB
02_maximum_00.txt AC 123 ms 56832 KiB
02_maximum_01.txt AC 125 ms 57348 KiB
02_maximum_02.txt AC 114 ms 54652 KiB
02_maximum_03.txt AC 132 ms 55832 KiB
02_maximum_04.txt AC 138 ms 56728 KiB
02_maximum_05.txt AC 149 ms 68356 KiB
02_maximum_06.txt AC 143 ms 68352 KiB
02_maximum_07.txt AC 138 ms 63148 KiB
02_maximum_08.txt AC 136 ms 63072 KiB
02_maximum_09.txt AC 130 ms 63228 KiB