96652024-02-23 20:19:41NagyLeoBináris fa magassága (50 pont)python3Time limit exceeded 40/50578ms16768 KiB
from sys import stdin, stdout
input=stdin.readline

def main2():
    N, M = map(int, input().split())
    # current_mods = {}

    corners_len = [0] * (2 ** N)
    elhossz = [1] * (2 ** N)
    # index=1
    # tav=N-1

    for i in range(N):
        ii = 2 ** i
        for j in range(ii):
            corners_len[ii + j] = N - i - 1

    for i in range(M):
        deepest = 0
        A, B = map(int, input().split())
        # current_mods[A] = B
        elhossz[A] = B
        curIndex = A
        while curIndex > 1:
            curIndex //= 2
            corners_len[curIndex] = max(corners_len[2 * curIndex] + elhossz[2 * curIndex],
                                        corners_len[2 * curIndex + 1] + elhossz[2 * curIndex + 1])
        stdout.write(str(corners_len[1])+"\n")


main2()
SubtaskSumTestVerdictTimeMemory
base40/50
1Accepted0/017ms11416 KiB
2Accepted0/0381ms14384 KiB
3Accepted2/220ms11752 KiB
4Accepted2/220ms12136 KiB
5Accepted2/220ms12232 KiB
6Accepted2/220ms12628 KiB
7Accepted3/320ms12612 KiB
8Accepted3/320ms12500 KiB
9Accepted3/320ms12772 KiB
10Accepted3/320ms13156 KiB
11Time limit exceeded0/2568ms6876 KiB
12Time limit exceeded0/2570ms6568 KiB
13Time limit exceeded0/2563ms6680 KiB
14Time limit exceeded0/2578ms6820 KiB
15Time limit exceeded0/2575ms7032 KiB
16Accepted2/2361ms15988 KiB
17Accepted2/2367ms15864 KiB
18Accepted2/2367ms16132 KiB
19Accepted2/2365ms16360 KiB
20Accepted3/3405ms16628 KiB
21Accepted3/3409ms16432 KiB
22Accepted3/3405ms16436 KiB
23Accepted3/3407ms16768 KiB