90412024-02-13 07:04:21PedriBináris fa magassága (50 pont)cpp17Wrong answer 0/503ms3908 KiB
#include <iostream>
#include <fstream>

using namespace std;
int n, m;


int main()
{
    ifstream f("be.in");
    f>>n>>m;
    int ossz=1;
    int t=1;
    for(int i=1;i<=n;i++){
        ossz=ossz*2;
        t=t*2;
    }
    ossz--;
    t=t/2;
    int a[ossz];
    a[1]=0;
    for(int i=2;i<=ossz;i++){
        a[i]=1;
    }
    for(int i=1;i<=m;i++){
        int x;
        f>>x;
        f>>a[x];
        int l[ossz]={0};
        l[1]=0;
        for(int j=2;j<=ossz;j++){
            l[j]=l[j/2]+a[j];
        }
        int s=0;
        for(int j=t;j<=ossz;j++){
            if(l[j]>s)s=l[j];
        }
        cout<<s<<endl;
    }




    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms1800 KiB
2Wrong answer0/03ms2012 KiB
3Wrong answer0/23ms2220 KiB
4Wrong answer0/23ms2332 KiB
5Wrong answer0/22ms2304 KiB
6Wrong answer0/23ms2680 KiB
7Wrong answer0/32ms2532 KiB
8Wrong answer0/32ms2636 KiB
9Wrong answer0/32ms2632 KiB
10Wrong answer0/32ms2596 KiB
11Wrong answer0/22ms2596 KiB
12Wrong answer0/23ms2824 KiB
13Wrong answer0/23ms3040 KiB
14Wrong answer0/22ms3016 KiB
15Wrong answer0/22ms3124 KiB
16Wrong answer0/22ms3020 KiB
17Wrong answer0/23ms3248 KiB
18Wrong answer0/22ms3228 KiB
19Wrong answer0/23ms3460 KiB
20Wrong answer0/33ms3676 KiB
21Wrong answer0/33ms3656 KiB
22Wrong answer0/33ms3784 KiB
23Wrong answer0/33ms3908 KiB