Cod sursa(job #1010730)

Utilizator leontinLeontin leontin Data 15 octombrie 2013 17:00:49
Problema Subsir crescator maximal Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.45 kb
#include<iostream>
#include<fstream>
 using namespace std;
 int main()
 {long n,v[100001],i,w[100001],max=0,y,x,j;
 ifstream f("scmax.in");
 ofstream g("scmax.out");
 f>>n>>x;
 y=1;
 v[1]=x;
 for(i=2;i<=n;i++)
 {f>>x;
 if(x>v[y])
 {y++;
 v[y]=x;}
 else
	 if(x<v[y])
 {y=1;
 v[y]=x;
 }
 if(max<y)
 {max=y;
 for(j=1;j<=max;j++)
	 w[j]=v[j];
 }
 }
 
 g<<max<<"\n";
 for(i=1;i<=max;i++)
	 g<<w[i]<<" ";
 

 f.close();
 g.close();
 }