알고리즘

[알고리즘] 백준 14659 - 한조서열정리하고옴ㅋㅋ (C++)

blueberrysoda 2024. 10. 17. 23:52

[문제 링크] : https://www.acmicpc.net/problem/14659

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int N;
int Arr[30001];
vector<int> V;

int main(){
    cin >> N;
    int inp;

    for(int i=0; i<N; i++){
        int inp;
        cin >> inp;
        V.push_back(inp);
    }

    int Ans = -1;

    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            if(V[i]>V[j]){
                Arr[i]++;
            }
            else{
                break;
            }
        }
        Ans = max(Arr[i], Ans);
    }
    cout << Ans << "\n";
    
    return 0;
}