Cod sursa(job #2439886)
Utilizator | Data | 17 iulie 2019 01:38:23 | |
---|---|---|---|
Problema | Subsir crescator maximal | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("scmax.in");
ofstream out("scmax.out");
int main()
{
int n, s=1, x, y, i=0, ymax=0;
long long v[100005];
in>>n>>x;
while(in>>y)
{
if(y>ymax && y>x)
{
v[i]=x;
i++;
v[i]=y;
s++;
ymax=y;
}
x=y;
}
n=i;
out<<s<<'\n';
for(i=0;i<=n;i++)
out<<v[i]<<' ';
return 0;
}