답안 #340003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340003 2020-12-26T14:57:51 Z Sprdalo Money (IZhO17_money) C++17
0 / 100
1 ms 364 KB
#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);
    for (auto& i : a)
        cin >> i;

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

    cout << sol << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -