94702024-02-22 09:26:311478Bináris fa magassága (50 pont)cpp17Elfogadva 50/50128ms4732 KiB
#include <bits/stdc++.h>  
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
ll MOD = 1e9 + 7;


 
int main()
{
	//ifstream cin("in.txt");
	int n, m;
	cin >> n >> m;

	vector<int> dp(1<<n);
	int x = 0;
	for(int j = n; j >= 1; j--){
		for(int i = (1<<j) - 1; i >= (1<<(j-1)); i--){
			dp[i] = x;
		}
		x++;
	}

	vector<int> e(1<<n, 1);

	while(m--){
		int a, b;
		cin >> a >> b;
		e[a] = b;

		int p = a / 2;
		while(p){
			dp[p] = max(dp[p * 2] + e[p * 2], dp[p * 2 + 1] + e[p * 2 + 1]);
			p /= 2;
		}
		cout << dp[1] << '\n';
	}




}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1812 KiB
2Elfogadva0/082ms2892 KiB
3Elfogadva2/24ms2360 KiB
4Elfogadva2/24ms2380 KiB
5Elfogadva2/24ms2652 KiB
6Elfogadva2/24ms2720 KiB
7Elfogadva3/34ms2788 KiB
8Elfogadva3/34ms2912 KiB
9Elfogadva3/34ms3008 KiB
10Elfogadva3/34ms3008 KiB
11Elfogadva2/286ms3792 KiB
12Elfogadva2/286ms3984 KiB
13Elfogadva2/286ms4052 KiB
14Elfogadva2/286ms4052 KiB
15Elfogadva2/285ms4204 KiB
16Elfogadva2/282ms4232 KiB
17Elfogadva2/283ms4248 KiB
18Elfogadva2/282ms4464 KiB
19Elfogadva2/2128ms4476 KiB
20Elfogadva3/383ms4480 KiB
21Elfogadva3/382ms4508 KiB
22Elfogadva3/382ms4508 KiB
23Elfogadva3/398ms4732 KiB