Cod sursa(job #2916551)

Utilizator andrew91beteringhe andrei andrew91 Data 30 iulie 2022 14:44:06
Problema Subsir crescator maximal Scor 20
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.76 kb
#include <fstream>
#include <vector>
#include <iterator>
using namespace std; 
typedef long long ll;

ifstream cin("scmax.in");
ofstream cout("scmax.out");
int main ()
{	
		

	/*ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  	*/
  	short n;
  	vector < int > vec;

  	cin >> n;

  	short nr = 0;
  	for ( int i = 1 ; i <= n; i++)
  	{
  		int x; 
  		cin >> x;

  		if ( nr == 0 )
  			vec.push_back (x), nr ++;
  		if ( x > vec.back() && x > vec.front() )
  			vec.push_back(x) , nr ++ ;
  		else
  			if ( x < vec.front() )
  			{
  				vec.clear();
  				nr = 1;
  				vec.push_back(x);
  			}
  	}	

  	cout << nr << endl;
  	for ( auto x : vec)
  	{
  		cout << x << ' ';
  	}
    return 0;
}