problem
solution
codes
#include<iostream>
#include<algorithm>
using namespace std;
int n, h[50], k[50], ans1, ans2 = 1;
int dp1[50], dp2[50], maxn;
int main(){
while(cin>>h[n]) n++;
dp1[0] = 1; dp2[0] = 1; k[0] = h[0];
for(int i = 1; i < n; i++){
maxn = 0;
for(int j = 0; j < i; j++)
if(h[j]>=h[i])maxn = max(maxn, dp1[j]);
dp1[i] = maxn+1;
ans1 = max(ans1, dp1[i]);
maxn = 0;
for(int j = 0; j < i; j++)
if(h[j]<=h[i])maxn = max(maxn, dp2[j]);
dp2[i] = maxn+1;
ans2 = max(ans2, dp2[i]);
}
cout<<ans1<<"
"<<ans2;
return 0;
}