Pagini recente » Cod sursa (job #68465) | Cod sursa (job #2644770) | Cod sursa (job #1926507) | Cod sursa (job #2652206) | Cod sursa (job #3214069)
#include <bits/stdc++.h>
using namespace std;
ifstream f("scmax.in");
ofstream g("scmax.out");
int n, v[100002], lmax, cnt = 1, st, dr, stmax=1, drmax;
int main()
{
f>>n;
f>>v[1];
for(int i = 2; i <= n+1; i++){
f>>v[i];
if(v[i] > v[i-1]){
cnt++;
dr = i;
}
else{
if(v[i] == v[i-1]){
cnt = cnt;
dr = i;
}
else{
if(cnt > lmax){
lmax = cnt;
stmax = st;
drmax = dr;
}
cnt = 1;
st = i;
}
}
}
g<<lmax<<'\n';
for(int i = stmax; i <= drmax; i++)
{
if(v[i] != v[i-1])
g<<v[i]<<' ';
}
}