122962024-12-11 15:45:01ercseferencBináris fa magassága (50 pont)cpp17Wrong answer 0/50600ms748 KiB
#include <iostream>
#include <cmath>
using namespace std;
int main()
{   
    int n,m,cs,v,r,k,s;
    cout<<"n,m="; 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;
        cout<<"cs,v="; 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
base0/50
1Wrong answer0/01ms320 KiB
2Time limit exceeded0/0584ms572 KiB
3Wrong answer0/24ms508 KiB
4Wrong answer0/24ms320 KiB
5Wrong answer0/24ms320 KiB
6Wrong answer0/24ms320 KiB
7Wrong answer0/34ms320 KiB
8Wrong answer0/36ms320 KiB
9Wrong answer0/38ms420 KiB
10Wrong answer0/38ms412 KiB
11Time limit exceeded0/2600ms664 KiB
12Time limit exceeded0/2600ms568 KiB
13Time limit exceeded0/2598ms656 KiB
14Time limit exceeded0/2570ms408 KiB
15Time limit exceeded0/2592ms568 KiB
16Time limit exceeded0/2600ms748 KiB
17Time limit exceeded0/2600ms568 KiB
18Time limit exceeded0/2589ms568 KiB
19Time limit exceeded0/2583ms568 KiB
20Time limit exceeded0/3600ms568 KiB
21Time limit exceeded0/3600ms568 KiB
22Time limit exceeded0/3593ms568 KiB
23Time limit exceeded0/3575ms568 KiB