Pagini recente » Istoria paginii utilizator/bolovannn | Cod sursa (job #1609170) | Cod sursa (job #1997725) | Cod sursa (job #337175) | Cod sursa (job #1550740)
#include <iostream>
#include <fstream>
#define nmax 100005
using namespace std;
int n, a[nmax], in, out, bi, bo, best, lmax;
void read(){
int x = 1, i=1;
ifstream f("scmax.in");
f >> n;
f >> a[1];
while(!f.eof()){
f >> x;
if(x != a[i]){
i++;
a[i] = x;
}
}
n = i;
}
void solve(){
in = out = 1;
bi = bo = 1;
best = -1;
lmax = 1;
for(int i = 1; i < n; i++){
if(a[i] < a[i+1]){
lmax++;
out = i+1;
if(lmax > best){
best = lmax;
bi = in;
bo = out;
//cout << best << " " << bi << " " << bo << "\n";
}
}
else{
lmax = 1;
in = out = i+1;
}
}
}
int main()
{
read();
solve();
ofstream g("scmax.out");
g << best << "\n";
for(int i=bi; i<=bo; i++)
g << a[i] << " ";
return 0;
}