Problem description If someone thinks it's just a mouth to eat, it's wrong.
All know that the tongue has such a characteristic, "from Jane into luxury, from luxury to simple" (according to good people, this law is also suitable for many other situations). In particular, if it is a sweet tooth, when you eat food is not as sweet as what you have just eaten in the front, it is very uncomfortable.
Da Bao is a clever foodie, of course, well versed in this way. Once he came to a snack street, ready to eat from one end of the street to the other. In order to eat well, he took the trouble to get a variety of food "delicacy." He refuses to go back to his unpleasant experience, and he has to be cool (as much as possible). Enter two rows of data in the format.
The first act an integer n, indicating the number of snacks on the snack street
The second behavior is n integers, representing the "delicacy" output format of n foods as an integer that indicates the number of times to eat well sample input 10
3 18 7 14 10 12 23 41 16 24 Sample output 6 data scale and convention delicacy is 0 to 100 integer
n<1000 1.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <fstream>
using namespace std;
int a[1001];
void Las (int x[],int n)
{
int i,k,max;
int f[1001];
F[0]=1;
for (i=1;i<n;i++)
{
max=0; Max should cling to the outer for
(k=0;k<i;k++) //For (k=1;k<i-1;k++)
{
if (A[k]) of the most-valued layer of the loop. <=A[I]&&MAX<F[K]) max=f[k];
}
f[i]=max+1;
}
MAX=F[0];
for (i=1;i<n;i++)
{
if (Max<f[i]) max=f[i];
}
cout<<max<<endl;
}
int main ()
{
int n;
while (Cin>>n)
{for
(int i=0;i<n;i++) cin>>a[i];
Las (a,n);
}
return 0;
}
2.
#include <stdio.h>
int main (void)
{
int num[1001];
int f[1001];
int n;
int Max;
int i,j;
scanf ("%d", &n);
for (i=1;i<=n;i++)
{
scanf ("%d", &num[i]);
}
for (i=n;i>=1;i--)
{
f[i]=1;
for (j=i+1;j<=n;j++)
{
if (Num[i]<=num[j]&&f[i]<=f[j])
{
f[i]=f[j]+1;
}
}
}
MAX=F[1];
for (i=2;i<=n;i++)
{
if (Max<f[i])
{
max=f[i];
}
}
printf ("%d", max);
return 0;
}