181252025-10-01 11:21:12szjBináris fa magassága (50 pont)cpp17Időlimit túllépés 20/50600ms2868 KiB
#include <bits/stdc++.h>
using namespace std;
int max = 0;
int main()
{
    //ifstream cin("f.txt");
    int i, n, m, a, b, n1,n2, j;
    cin >> n >> m;
    int num = pow(2, n), id = pow(2, n-1), ma = 0;
    int t[num];
    fill(t, t+num, n-1);
    map<int, int> vec;
    map<int, int> volt;
    for(i=id; i<num; i++)vec.insert({i, i-id});
    for(i=0; i<m; i++)
    {
      cin >> a >> b;
      if(volt.count(a))
      {
          n1 =b;
          b -= volt[a];
          volt[a]=n1;
      }
      else
      {
          volt.insert({a, b});
          b--;
      }
      n1 = a;
      n2 = a;
      while(n1<id)
      {
          n1*=2;
          n2 = n2*2+1;
      }
      for(j=vec[n1]; j<=vec[n2]; j++)
      {
          t[j]+=b;
      }
      cout << *max_element(t, t+num)<<endl;
    }
    return 0;
}

RészfeladatÖsszpontTesztVerdiktIdőMemória
base20/50
1Elfogadva0/01ms316 KiB
2Időlimit túllépés0/0583ms2356 KiB
3Elfogadva2/23ms316 KiB
4Elfogadva2/23ms316 KiB
5Elfogadva2/23ms316 KiB
6Elfogadva2/23ms316 KiB
7Elfogadva3/33ms508 KiB
8Elfogadva3/33ms512 KiB
9Elfogadva3/34ms316 KiB
10Elfogadva3/34ms500 KiB
11Időlimit túllépés0/2600ms2760 KiB
12Időlimit túllépés0/2600ms2732 KiB
13Időlimit túllépés0/2600ms2732 KiB
14Időlimit túllépés0/2582ms2868 KiB
15Időlimit túllépés0/2588ms2864 KiB
16Időlimit túllépés0/2587ms2252 KiB
17Időlimit túllépés0/2587ms2356 KiB
18Időlimit túllépés0/2591ms2356 KiB
19Időlimit túllépés0/2591ms2352 KiB
20Időlimit túllépés0/3591ms2656 KiB
21Időlimit túllépés0/3592ms2864 KiB
22Időlimit túllépés0/3587ms2868 KiB
23Időlimit túllépés0/3579ms2612 KiB