90432024-02-13 07:12:18PedriBináris fa magassága (50 pont)cpp17Time limit exceeded 20/50600ms4260 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;
        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/0600ms1856 KiB
3Accepted2/24ms2112 KiB
4Accepted2/24ms2336 KiB
5Accepted2/24ms2576 KiB
6Accepted2/24ms2768 KiB
7Accepted3/34ms2984 KiB
8Accepted3/34ms3192 KiB
9Accepted3/34ms3316 KiB
10Accepted3/34ms3408 KiB
11Time limit exceeded0/2574ms3288 KiB
12Time limit exceeded0/2564ms3348 KiB
13Time limit exceeded0/2546ms3504 KiB
14Time limit exceeded0/2566ms3604 KiB
15Time limit exceeded0/2569ms3824 KiB
16Time limit exceeded0/2550ms3936 KiB
17Time limit exceeded0/2558ms4088 KiB
18Time limit exceeded0/2564ms4116 KiB
19Time limit exceeded0/2552ms4260 KiB
20Time limit exceeded0/3556ms4184 KiB
21Time limit exceeded0/3546ms4252 KiB
22Time limit exceeded0/3561ms4188 KiB
23Time limit exceeded0/3545ms4104 KiB