82612024-01-13 21:14:03ananászBináris fa magassága (50 pont)csharpWrong answer 0/50273ms32576 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/028ms21108 KiB
2Wrong answer0/0261ms30032 KiB
3Wrong answer0/229ms21848 KiB
4Wrong answer0/228ms22212 KiB
5Wrong answer0/228ms22564 KiB
6Wrong answer0/229ms22812 KiB
7Wrong answer0/329ms22984 KiB
8Wrong answer0/329ms22864 KiB
9Wrong answer0/329ms22940 KiB
10Wrong answer0/329ms22940 KiB
11Wrong answer0/2273ms30964 KiB
12Wrong answer0/2270ms31192 KiB
13Wrong answer0/2266ms31316 KiB
14Wrong answer0/2261ms31432 KiB
15Wrong answer0/2268ms31984 KiB
16Wrong answer0/2261ms31920 KiB
17Wrong answer0/2224ms31772 KiB
18Wrong answer0/2223ms32208 KiB
19Wrong answer0/2218ms32456 KiB
20Wrong answer0/3263ms32052 KiB
21Wrong answer0/3263ms32152 KiB
22Wrong answer0/3221ms32576 KiB
23Wrong answer0/3259ms32472 KiB