83002024-01-14 12:34:47ananászBináris fa magassága (50 pont)csharpWrong answer 0/50273ms34172 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace binarisfa
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] st = Console.ReadLine().Split();
            int N = int.Parse(st[0]);
            int M = int.Parse(st[1]);
            long db = (long)Math.Pow(2, N) - 1;
            int[] hossz = new int[db];
            for (int i = 0; i < M; i++)
            {
                st = Console.ReadLine().Split();
                hossz[int.Parse(st[0]) - 1] = int.Parse(st[1]);
            }
            int id = 1;
            while (id<db)
            {
                if (hossz[id]==0)
                {
                    hossz[id]++;
                }
                hossz[id] += hossz[(id+1) / 2-1];
                id++;
            }
            for (long i = db-(long)Math.Pow(2,N-1); i < db; i++)
            {
                Console.WriteLine(hossz[i]);
            }
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/029ms21240 KiB
2Wrong answer0/0226ms29868 KiB
3Wrong answer0/230ms22048 KiB
4Wrong answer0/230ms22324 KiB
5Wrong answer0/228ms22648 KiB
6Wrong answer0/228ms23328 KiB
7Wrong answer0/330ms23132 KiB
8Wrong answer0/329ms23964 KiB
9Wrong answer0/330ms23744 KiB
10Wrong answer0/330ms24628 KiB
11Wrong answer0/2224ms32680 KiB
12Wrong answer0/2263ms32548 KiB
13Wrong answer0/2230ms33088 KiB
14Wrong answer0/2244ms33248 KiB
15Wrong answer0/2256ms33020 KiB
16Wrong answer0/2252ms33220 KiB
17Wrong answer0/2261ms33576 KiB
18Wrong answer0/2226ms33624 KiB
19Wrong answer0/2217ms33664 KiB
20Wrong answer0/3259ms33952 KiB
21Wrong answer0/3216ms34172 KiB
22Wrong answer0/3273ms33740 KiB
23Wrong answer0/3261ms33640 KiB