Cod sursa(job #2477567)

Utilizator XXMihaiXX969Gherghinescu Mihai Andrei XXMihaiXX969 Data 20 octombrie 2019 17:59:00
Problema Subsir crescator maximal Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.58 kb
#include <iostream>
#include <algorithm>
#include <fstream>

using namespace std;

ifstream in("scmax.in");
ofstream out("scmax.out");

long long v[100007];

int dp[2][100007];
int main()
{
    ios::sync_with_stdio(false);
    in.tie(0);
    int n;
    in >> n;
    for(int i = 1 ;i <= n;i++)
        in >> v[i];
        int l = 0;
    for(int i = 1; i <= n; i++ , l = 1-l)
        for(int j = 1; j <= n;j++)
        if(v[i] < v[j])
        dp[l][j] = dp[1-l][j]+1;
    else
        dp[l][j] = max(dp[1-l][j],dp[l][j-1]);
    out << dp[1][n];
    return 0;
}