32602023-02-23 13:23:03sztomiRészekre (40)cpp11Accepted 40/4045ms5000 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];


    vector<int> vegek;
    int db = 0;
    int ki;
    int b, j, kozep;
    for(int i = n - 1; i >= 0; i--){
        // adottnal legkisebb nagyobb
        ki = -1;
        b = 0;
        j = vegek.size() - 1;
        while(b <= j){
            kozep = (b + j) / 2;

            if(vegek[kozep] > a[i]){
                ki = kozep;
                j = kozep - 1;
            }
            else{
                b = kozep + 1;
            }
        }

        if(ki == -1){
            vegek.push_back(a[i]);
            db++;
        }
        else{
            vegek[ki] = a[i];
        }

    }

    cout << db << '\n';
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/045ms2836 KiB
3Accepted2/23ms2268 KiB
4Accepted2/23ms2428 KiB
5Accepted2/23ms2644 KiB
6Accepted3/33ms3008 KiB
7Accepted3/34ms2960 KiB
8Accepted3/34ms3160 KiB
9Accepted3/36ms3276 KiB
10Accepted3/320ms4044 KiB
11Accepted3/332ms4676 KiB
12Accepted3/339ms5000 KiB
13Accepted4/439ms4880 KiB
14Accepted4/439ms4980 KiB
15Accepted5/539ms4756 KiB