87912024-01-30 17:57:43KezdőBináris fa magassága (50 pont)python3Time limit exceeded 20/50600ms13096 KiB
from sys import stdin,stdout

def main():
    N,M = [int(i) for i in stdin.readline().split()]
    f = [0,0]+[1]*(2**N-2)
    h = [0]*2**(N-1) + [N-1]*2**(N-1)
    u = 2**(N-1)
    #print(f)

    def holvan(x):
        s = 1
        while x >= 2**s:
            s += 1
        return s

    for i in range(M):
        a,uj = [int(i) for i in input().split()]
        b = uj-f[a]
        f[a] = uj
        sor = holvan(a)
        le = N-sor
        maxi = N-1
        for i in range(a*2**le,a*2**le+2**le):
            h[i] += b
        maxi = max(h[u:])
        stdout.write(str(maxi)+'\n')
main()    
SubtaskSumTestVerdictTimeMemory
base20/50
1Accepted0/017ms11240 KiB
2Time limit exceeded0/0573ms6292 KiB
3Accepted2/225ms11740 KiB
4Accepted2/226ms12152 KiB
5Accepted2/226ms12268 KiB
6Accepted2/226ms12540 KiB
7Accepted3/328ms12760 KiB
8Accepted3/328ms12744 KiB
9Accepted3/332ms12660 KiB
10Accepted3/332ms13096 KiB
11Time limit exceeded0/2600ms6812 KiB
12Time limit exceeded0/2559ms6940 KiB
13Time limit exceeded0/2564ms6940 KiB
14Time limit exceeded0/2568ms7096 KiB
15Time limit exceeded0/2572ms7040 KiB
16Time limit exceeded0/2563ms7816 KiB
17Time limit exceeded0/2547ms7820 KiB
18Time limit exceeded0/2563ms8092 KiB
19Time limit exceeded0/2575ms8008 KiB
20Time limit exceeded0/3568ms7316 KiB
21Time limit exceeded0/3546ms7376 KiB
22Time limit exceeded0/3560ms7380 KiB
23Time limit exceeded0/3566ms7276 KiB