84192024-01-15 18:46:46birozsBináris fa magassága (50 pont)python3Time limit exceeded 20/50600ms13076 KiB
N,M = map(int,input().split())
mag = [N-1] * 2**(N-1)
lista = [1] * 2**N
mo = []
for i in range(M):
    csucs,hossz = map(int,input().split())
    aktsor = 1
    while not (csucs > 2**(aktsor-1) and csucs < 2**(aktsor+1)):
        aktsor += 1
    aktsor += 1
    levelszam = 2**(N-aktsor)
    elsolevel = csucs * 2**(N-aktsor)
    valtozas = hossz - lista[csucs]
    lista[csucs] = hossz
    for i in range(elsolevel,elsolevel+levelszam):
        mag[i-2**(N-1)] += valtozas
    mo.append(max(mag))
for x in mo:
    print(x)

SubtaskSumTestVerdictTimeMemory
base20/50
1Accepted0/017ms11368 KiB
2Time limit exceeded0/0600ms5368 KiB
3Accepted2/223ms11896 KiB
4Accepted2/224ms12416 KiB
5Accepted2/225ms12420 KiB
6Accepted2/225ms12352 KiB
7Accepted3/328ms12528 KiB
8Accepted3/332ms12204 KiB
9Accepted3/337ms12660 KiB
10Accepted3/337ms13076 KiB
11Time limit exceeded0/2577ms5936 KiB
12Time limit exceeded0/2575ms6032 KiB
13Time limit exceeded0/2579ms6368 KiB
14Time limit exceeded0/2547ms6344 KiB
15Time limit exceeded0/2551ms6544 KiB
16Time limit exceeded0/2587ms7476 KiB
17Time limit exceeded0/2579ms7364 KiB
18Time limit exceeded0/2560ms8056 KiB
19Time limit exceeded0/2575ms7880 KiB
20Time limit exceeded0/3564ms7244 KiB
21Time limit exceeded0/3568ms7160 KiB
22Time limit exceeded0/3579ms7160 KiB
23Time limit exceeded0/3579ms7124 KiB