131882025-01-06 22:17:20mateBináris fa magassága (50 pont)cpp17Time limit exceeded 20/50600ms756 KiB
#include <bits/stdc++.h>
using namespace std;

vector <int> v;
int n,m;


int ma(int csucs){
	if(2*csucs > (1<<n)-1)	return v[csucs];
	return max(ma(2*csucs),ma(2*csucs + 1)) + v[csucs];
	

}


int main() {
	cin.tie(0); ios::sync_with_stdio(0);
	cin >> n >> m;
	v.resize((1 << (n))+1,1);
	while(m--){
		int a,b; cin >> a >> b;
		int maxi = 0;
		v[a] = b;
		maxi = ma(1) - 1;
		cout << maxi << '\n';
		
	}

}
SubtaskSumTestVerdictTimeMemory
base20/50
1Accepted0/01ms316 KiB
2Time limit exceeded0/0582ms692 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms508 KiB
5Accepted2/21ms368 KiB
6Accepted2/21ms316 KiB
7Accepted3/31ms316 KiB
8Accepted3/32ms348 KiB
9Accepted3/32ms316 KiB
10Accepted3/32ms316 KiB
11Time limit exceeded0/2600ms696 KiB
12Time limit exceeded0/2600ms696 KiB
13Time limit exceeded0/2600ms696 KiB
14Time limit exceeded0/2584ms692 KiB
15Time limit exceeded0/2580ms756 KiB
16Time limit exceeded0/2583ms688 KiB
17Time limit exceeded0/2584ms564 KiB
18Time limit exceeded0/2583ms756 KiB
19Time limit exceeded0/2586ms564 KiB
20Time limit exceeded0/3588ms700 KiB
21Time limit exceeded0/3588ms564 KiB
22Time limit exceeded0/3579ms696 KiB
23Time limit exceeded0/3587ms688 KiB