Cod sursa(job #1486501)
Utilizator | Data | 14 septembrie 2015 23:00:40 | |
---|---|---|---|
Problema | Subsir crescator maximal | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.53 kb |
#include <stdio.h>
int n;
int a[100000];
int minLastForThisLength[100003];
int main(void){
scanf("%d", &n);
for (int i=0; i<n; i++){
scanf("%d", &a[i]);
}
minLastForThisLength[0] = 0;
for (int i=1; i<=n; i++) minLastForThisLength[i] = 200000;
for (int i=0; i<n; i++){
for (int j=1; j<=n; j++){
if (minLastForThisLength[j-1]<a[i] && minLastForThisLength[j]>a[i]) minLastForThisLength[j] = a[i];
}
}
int i;
i=1;
while (minLastForThisLength[i]<200000) i++;
printf("%d\n", i-1);
return 0;
}