92252024-02-18 23:30:58KezdőBináris fa magassága (50 pont)python3Time limit exceeded 20/50579ms15684 KiB
from sys import stdin,stdout

def main():
    N,M = [int(i) for i in stdin.readline().split()]
    t = 2**N
    a = [N]   # alatta levő "mélység"
    k = 1
    for i in range(1,N+1):
        a = a + [N-i]*k
        k *= 2
    h = [1]*2**N

    for i in range(M):
        cs,x = [int(i) for i in input().split()]
        h[cs] = x
        while cs > 1:
            cs //= 2
            a[cs] = max(h[2*cs]+a[2*cs], h[2*cs+1]+a[2*cs+1])
        print(a[1])
    
main()    
SubtaskSumTestVerdictTimeMemory
base20/50
1Accepted0/017ms11332 KiB
2Time limit exceeded0/0552ms5132 KiB
3Accepted2/223ms11732 KiB
4Accepted2/225ms12132 KiB
5Accepted2/225ms12396 KiB
6Accepted2/224ms12380 KiB
7Accepted3/325ms12484 KiB
8Accepted3/325ms12384 KiB
9Accepted3/325ms12684 KiB
10Accepted3/326ms12584 KiB
11Time limit exceeded0/2564ms6276 KiB
12Time limit exceeded0/2579ms6192 KiB
13Time limit exceeded0/2564ms6264 KiB
14Time limit exceeded0/2542ms6308 KiB
15Time limit exceeded0/2564ms6276 KiB
16Time limit exceeded0/2566ms6596 KiB
17Time limit exceeded0/2560ms15348 KiB
18Time limit exceeded0/2568ms15684 KiB
19Time limit exceeded0/2566ms6980 KiB
20Time limit exceeded0/3559ms6860 KiB
21Time limit exceeded0/3555ms6872 KiB
22Time limit exceeded0/3568ms6688 KiB
23Time limit exceeded0/3579ms6968 KiB