Cod sursa(job #1815116)

Utilizator abcdefghijkalfabet abcdefghijk Data 24 noiembrie 2016 20:44:19
Problema Subsir crescator maximal Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.45 kb
#include <fstream>

using namespace std;

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

int n, a[100001], k, i, s, b;

int main()  {
  fin >> n;
  a[0] = 2000000001;
  for (i = 1; i <= n; i++)  {
    fin >> a[i];
    if (a[i] < a[i - 1])
      k = 1, s = i;
    else  { if (a[i] > a[i - 1])
    k++;
    b++;
    }
  }
  fout << k << '\n';
  for (i = s; i <= b + s; i++)
    if (a[i] != a[i - 1])
      fout << a[i] << ' ';
}