Pagini recente » Cod sursa (job #1749895) | Cod sursa (job #1522153) | Cod sursa (job #1845429) | Cod sursa (job #1681248) | Cod sursa (job #1857686)
#include <stdio.h>
#include <iostream>
#define MAX 100000
using namespace std;
int v[MAX], lmax[MAX];
int main()
{
FILE *fin, *fout;
int n, i, max, j;
fin = fopen("scmax.in", "r");
fout = fopen("scmax.out", "w");
fscanf(fin, "%d", &n);
for(i = 0; i < n; i++)fscanf(fin, "%d", &v[i]);
lmax[0] = 1;
for(i = 1; i < n; i++)
{
max = 0;
for(j = i - 1; j >= 0; j--)
if(v[j] <= v[i] && max < lmax[j])max = lmax[j];
lmax[i] = max + 1;
}
max = 0;
for(i = 0; i < n; i++)if(max < lmax[i])max = lmax[i];
fprintf(fout, "%d", max);
fclose( fin );
fclose( fout );
return 0;
}