45822023-03-30 09:54:04TortelliniJrÁtvágás (75 pont)csharpPartially correct 71/75370ms34916 KiB
using System;
using System.Linq;
namespace Átvágás
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            int[] kapcs = new int[num + 1];
            int[] inp = new int[2];
            for (int i = 0; i < num - 1; i++)
            {
                inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                kapcs[inp[0]]++;
                kapcs[inp[1]]++;
            }
            int er1 = 0;
            int er2 = int.MaxValue;
            if (Array.IndexOf(kapcs, 1) == -1)
            {
                er1 = 1;
            }
            for (int i = 0; i < num; i++)
            {
                if (kapcs[i] - 2 > 0)
                {
                    er1 += kapcs[i] - 2;
                }
                if (er2 > num - 1 - kapcs[i])
                {
                    er2 = num - 1 - kapcs[i];
                }
            }
            Console.WriteLine(er1 + " " + er2);
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base71/75
1Accepted0/032ms21668 KiB
2Accepted0/030ms22488 KiB
3Accepted0/048ms27384 KiB
4Accepted4/430ms22956 KiB
5Accepted4/430ms23056 KiB
6Accepted4/430ms23584 KiB
7Accepted4/430ms23684 KiB
8Partially correct2/429ms23968 KiB
9Partially correct2/430ms24044 KiB
10Accepted4/4333ms33668 KiB
11Accepted4/4351ms33484 KiB
12Accepted4/4361ms33764 KiB
13Accepted4/4361ms33636 KiB
14Accepted4/4358ms33928 KiB
15Accepted4/4367ms34120 KiB
16Accepted4/4361ms34120 KiB
17Accepted4/4363ms34648 KiB
18Accepted5/5365ms34916 KiB
19Accepted6/6361ms34672 KiB
20Accepted6/6370ms34724 KiB
21Accepted2/232ms25228 KiB