32572023-02-23 12:43:53TuruTamasRészekre (40)cpp17Time limit exceeded 18/40573ms13712 KiB
#include <bits/stdc++.h>
using namespace std;

vector<stack<int>> x;
int N;

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> N;
    int a;
    for (size_t i = 0; i < N; i++)
    {
        cin >> a;
        bool f = false;
        int c = 0;
        for (auto& s : x)
        {
            c++;
            if (s.top() < a) {
                
                s.push(a);
                f = true;
                break;
            }
        }
        if (!f) {
            x.push_back(stack<int>());
            x.back().push(a);
        }
    }
    cout << x.size();
    // for (auto s : x)
    // {
    //     while (!s.empty())
    //     {
    //         cout << s.top() << " ";
    //         s.pop();
    //     }
    //     cout << "\n";
    // }
    
}
SubtaskSumTestVerdictTimeMemory
base18/40
1Accepted0/03ms1700 KiB
2Accepted0/085ms3852 KiB
3Accepted2/23ms2100 KiB
4Accepted2/23ms2456 KiB
5Accepted2/23ms2944 KiB
6Accepted3/33ms3460 KiB
7Accepted3/34ms4060 KiB
8Accepted3/38ms5620 KiB
9Accepted3/324ms8236 KiB
10Time limit exceeded0/3550ms13420 KiB
11Time limit exceeded0/3555ms13696 KiB
12Time limit exceeded0/3540ms13712 KiB
13Time limit exceeded0/4564ms13684 KiB
14Time limit exceeded0/4573ms13592 KiB
15Time limit exceeded0/5560ms13532 KiB