Mai intai trebuie sa te autentifici.
Cod sursa(job #2548748)
| Utilizator | Data | 16 februarie 2020 23:25:41 | |
|---|---|---|---|
| Problema | Subsir crescator maximal | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.89 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream r("scmax.in");
ofstream w("scmax.out");
int v[100001];
int main()
{
int n, i, k, a=0, b=0, nrs=1, cnt=0;
r>>n;
for(i=0; i<n; i++)
{
r>>k;
if(k >= a)
{
if(k>a)
{
b++;
a=k;
v[cnt]=k;
cnt++;
}
}
else
{
if(b>nrs)
{
nrs=b;
b=1;
a=0;
}
else
{
b=1;
a=0;
}
cnt=1;
v[0]=k;
}
}
if(b>nrs)
{
nrs=b;
}
w<<nrs<<"\n";
int cnt1=0;
while(v[cnt1]!=0){
w<<v[cnt1]<<" ";
cnt1++;
}
return 0;
}
