122242024-12-10 07:26:09madvirBináris fa magassága (50 pont)python3Runtime error 0/5016ms3084 KiB
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int n, m, x, y, maxut;
    cin >> n >> m;
    vector<int> mag;
    int fel[65537];
    fill_n(fel,65537,1);
    int q=pow(2,n-1), w=pow(2, n), ut;
    for(int i=0; i<m; i++) {
        cin >> x >> y;
        fel[x]=y;
        maxut=0;
        for(int j=q; j<w; j++) {
            x=j;
            ut=0;
            //cout << "j=" << j << endl;
            while(x!=1) {
                ut+=fel[x];
                //cout << "ut=" <<ut << ", ";
                x=(x-x%2)/2;
                //cout << "x=" << x << endl;
            }
            if(ut>maxut) {
                maxut=ut;
            }
        }
        mag.push_back(maxut);
    }
    for(vector<int>::iterator ptr=mag.begin(); ptr!=mag.end(); ptr++) {
        cout << *ptr << endl;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Runtime error0/016ms2872 KiB
2Runtime error0/016ms2868 KiB
3Runtime error0/216ms2864 KiB
4Runtime error0/214ms2868 KiB
5Runtime error0/216ms2868 KiB
6Runtime error0/216ms2868 KiB
7Runtime error0/316ms2872 KiB
8Runtime error0/314ms3016 KiB
9Runtime error0/316ms2876 KiB
10Runtime error0/314ms3032 KiB
11Runtime error0/216ms3064 KiB
12Runtime error0/216ms2872 KiB
13Runtime error0/214ms2872 KiB
14Runtime error0/214ms3084 KiB
15Runtime error0/214ms2996 KiB
16Runtime error0/214ms3000 KiB
17Runtime error0/216ms3056 KiB
18Runtime error0/216ms2872 KiB
19Runtime error0/216ms2956 KiB
20Runtime error0/316ms3020 KiB
21Runtime error0/316ms2912 KiB
22Runtime error0/314ms2960 KiB
23Runtime error0/314ms2868 KiB