제출 #340006

#제출 시각아이디문제언어결과실행 시간메모리
340006SprdaloMoney (IZhO17_money)C++17
0 / 100
1 ms364 KiB
#include <bits/stdc++.h>

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

vi a, vis;
int n;

int lis(){
    vi d(n,0), last(n, -1);
    for (int i = 0; i < n; ++i){
        if (vis[i]) continue;

        d[i] = 1;
        for (int j = 0; j < i; ++j){
            if (!vis[j] && a[j] < a[i] && d[i] < d[j]+1){
                last[i] = j;
                d[i] = d[j]+1;
            }
        }
    }

    int ind = max_element(d.begin(), d.end()) - d.begin(), sol = d[ind];
    while(ind != -1){
        vis[ind] = 1;
        ind = last[ind];
    }

    return sol;
}

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr); 

    cin >> n;   

    a = vi(n);
    vis = vi(n);
    int x = -100;
    bool ok = 1;
    for (auto& i : a){
        cin >> i;
        if (i < x)
            ok = 0;

        x = i;
    }

    if (ok)
        return cout << "0\n", 0;

    int sol = 0, cnt = 0;
    while(cnt < n){
        cnt += lis();
        ++sol;
    }

    cout << sol << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...