Cod sursa(job #3315873)

Utilizator _.diannaq._Bengescu Diana _.diannaq._ Data 16 octombrie 2025 13:57:39
Problema Subsir crescator maximal Scor 65
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.59 kb
#include <bits/stdc++.h>
using namespace std;

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

int v[100001];
int d[100001];

int main() {
    const int INF = 2000000000;
    int n;
    fin >> n;

    for(int i = 1; i <= n; i++) {
        fin >> v[i];
        d[i] = INF;
    }

 

    for(int i = 1; i <= n; i++) {
        int a = lower_bound(d + 1, d + n + 1, v[i]) - d;
        d[a] = v[i];
    }

    int b = lower_bound(d + 1, d + n + 1, INF) - d - 1;
    fout << b<<'\n';
  
  
  for(int i=1;i<=b;i++){
      
      fout<<d[i]<<" ";
  }


    return 0;
}