122982024-12-11 15:49:14ercseferencBináris fa magassága (50 pont)cpp17Time limit exceeded 20/50600ms756 KiB
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n,m,cs,v,r,k,s;
    cin>>n; cin>>m;
    int p=pow(2,n)-1;
    int a[p+1]; for(int i=2; i<=p; i++){a[i]=1;}
    a[0]=0; a[1]=0;
    for(int i=0; i<m; i++){
        r=0;
        cin>>cs; cin>>v;
        a[cs]=v;
        for(int i=pow(2,n-1); i<pow(2,n); i++){
            s=0; k=i;
            while(k!=0){
                s=s+a[k]; k=k/2;}
            if(s>r) r=s;}
        cout<<r<<endl;}
    return 0;}
SubtaskSumTestVerdictTimeMemory
base20/50
1Accepted0/01ms508 KiB
2Time limit exceeded0/0578ms756 KiB
3Accepted2/23ms320 KiB
4Accepted2/23ms320 KiB
5Accepted2/23ms320 KiB
6Accepted2/23ms320 KiB
7Accepted3/34ms332 KiB
8Accepted3/34ms320 KiB
9Accepted3/37ms560 KiB
10Accepted3/37ms320 KiB
11Time limit exceeded0/2600ms664 KiB
12Time limit exceeded0/2600ms568 KiB
13Time limit exceeded0/2598ms568 KiB
14Time limit exceeded0/2592ms568 KiB
15Time limit exceeded0/2589ms568 KiB
16Time limit exceeded0/2600ms568 KiB
17Time limit exceeded0/2598ms568 KiB
18Time limit exceeded0/2587ms756 KiB
19Time limit exceeded0/2591ms756 KiB
20Time limit exceeded0/3600ms604 KiB
21Time limit exceeded0/3600ms568 KiB
22Time limit exceeded0/3588ms568 KiB
23Time limit exceeded0/3582ms568 KiB