90442024-02-13 07:18:29PedriBináris fa magassága (50 pont)cpp17Time limit exceeded 20/50600ms3832 KiB
#include <iostream>
#include <fstream>
#include <cmath>

using namespace std;
int n, m;


int main()
{
    ifstream f("be.in");
    cin>>n>>m;
    int ossz=pow(2, n)-1;
    int t=pow(2, n-1);
    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;
        int s=0;
        for(int j=2;j<=ossz;j++){
            l[j]=l[j/2]+a[j];
            if(l[j]>s)s=l[j];
        }
        cout<<s<<endl;
    }




    return 0;
}
SubtaskSumTestVerdictTimeMemory
base20/50
1Accepted0/03ms1808 KiB
2Time limit exceeded0/0600ms1792 KiB
3Accepted2/24ms2216 KiB
4Accepted2/24ms2464 KiB
5Accepted2/24ms2508 KiB
6Accepted2/24ms2636 KiB
7Accepted3/34ms2852 KiB
8Accepted3/34ms3096 KiB
9Accepted3/34ms3148 KiB
10Accepted3/34ms3276 KiB
11Time limit exceeded0/2600ms3228 KiB
12Time limit exceeded0/2565ms3356 KiB
13Time limit exceeded0/2569ms3292 KiB
14Time limit exceeded0/2554ms3488 KiB
15Time limit exceeded0/2550ms3464 KiB
16Time limit exceeded0/2561ms3552 KiB
17Time limit exceeded0/2549ms3748 KiB
18Time limit exceeded0/2577ms3780 KiB
19Time limit exceeded0/2556ms3700 KiB
20Time limit exceeded0/3580ms3776 KiB
21Time limit exceeded0/3564ms3732 KiB
22Time limit exceeded0/3569ms3676 KiB
23Time limit exceeded0/3552ms3832 KiB