89172024-02-05 08:02:20AncsaBináris fa magassága (50 pont)cpp17Wrong answer 0/50600ms4768 KiB
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

int main()
{

    int n;
    cin>>n;
    int lszam=pow(2,n-1), szam=2*lszam;

    vector <int> fa(szam);
    vector <int> levelek(lszam+1);
    for(int i=0;i<=lszam;i++)
         levelek.at(i)=n-1;

    fa.at(1)=0;
    for (int i=2;i<szam;i++)
        fa.at(i)=1;
    int muv;
    cin >>muv;
    int hol, mire;
    for (int i=0;i<muv;i++)
    {
        cin>>hol>>mire;
        int szint =(int)log2(hol)+1;
        int tav=n-szint, valt=mire-fa.at(hol);
        fa.at(hol)=mire;
        for(int i=hol*pow(2,tav)-(lszam-1);i<=(hol+1)*pow(2,tav)-lszam;i++)
            if(mire != 0)
              levelek.at(i)+=valt;
        cout<<*max_element(levelek.begin(),levelek.end());
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms1808 KiB
2Time limit exceeded0/0586ms1608 KiB
3Wrong answer0/24ms2220 KiB
4Wrong answer0/24ms2472 KiB
5Wrong answer0/24ms2676 KiB
6Wrong answer0/24ms2888 KiB
7Wrong answer0/34ms3096 KiB
8Wrong answer0/34ms3276 KiB
9Wrong answer0/36ms3396 KiB
10Wrong answer0/34ms3392 KiB
11Time limit exceeded0/2600ms3156 KiB
12Time limit exceeded0/2546ms3372 KiB
13Time limit exceeded0/2558ms3604 KiB
14Time limit exceeded0/2554ms3804 KiB
15Time limit exceeded0/2541ms4028 KiB
16Time limit exceeded0/2600ms4232 KiB
17Time limit exceeded0/2565ms4212 KiB
18Time limit exceeded0/2577ms4408 KiB
19Time limit exceeded0/2560ms4640 KiB
20Time limit exceeded0/3556ms4584 KiB
21Time limit exceeded0/3577ms4656 KiB
22Time limit exceeded0/3577ms4644 KiB
23Time limit exceeded0/3560ms4768 KiB