Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n;
- int niza[105];
- int dp[100];
- int l(int i){
- if(dp[i]!=-1){
- return dp[i];
- }
- int ss=0;
- for(int k=i+1; k<n; k++){
- if(niza[i]>=niza[k]){
- ss=max(ss, l(k)+1);
- }
- }
- dp[i]=ss;
- return dp[i];
- }
- int main()
- {
- cin>>n;
- for(int i=0; i<n; i++){
- cin>>niza[i];
- dp[i]=-1;
- }
- int ss=0;
- for(int i=0; i<n; i++){
- ss=max(ss, l(i)+1);
- }
- cout<<ss<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement