90422024-02-13 07:05:06PedriBináris fa magassága (50 pont)cpp17Time limit exceeded 20/50600ms3432 KiB
#include <iostream>
#include <fstream>

using namespace std;
int n, m;


int main()
{
    ifstream f("be.in");
    cin>>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;
        cin>>x;
        cin>>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
base20/50
1Accepted0/03ms1808 KiB
2Time limit exceeded0/0600ms1800 KiB
3Accepted2/24ms2056 KiB
4Accepted2/24ms2120 KiB
5Accepted2/24ms2404 KiB
6Accepted2/24ms2348 KiB
7Accepted3/34ms2544 KiB
8Accepted3/34ms2680 KiB
9Accepted3/34ms2884 KiB
10Accepted3/34ms3136 KiB
11Time limit exceeded0/2600ms3100 KiB
12Time limit exceeded0/2545ms3076 KiB
13Time limit exceeded0/2564ms3220 KiB
14Time limit exceeded0/2556ms3336 KiB
15Time limit exceeded0/2560ms3144 KiB
16Time limit exceeded0/2564ms3152 KiB
17Time limit exceeded0/2549ms3172 KiB
18Time limit exceeded0/2573ms3304 KiB
19Time limit exceeded0/2552ms3124 KiB
20Time limit exceeded0/3569ms3128 KiB
21Time limit exceeded0/3573ms3188 KiB
22Time limit exceeded0/3569ms3196 KiB
23Time limit exceeded0/3569ms3432 KiB