The input consists of a sequence of numbers a, a[2, ] . . . , a[n]. Your task is to design an O(n2) algorithm that finds an increasing subsequence with the maximum possible sum. An increasing subsequence is given by a sequence of indices 1 ≤ i1 < i2 < … < ik ≤ n such that a[i1] ≤ a[i2] ≤ … ≤ a[ik]. Note the the indices defining the subsequence are not necessarily consecutive numbers.
Your algorithm should work in time O(n2).
For example, for sequence 1, 14, 5, 6, 2, 3, the increasing subsequence 1, 14 has the largest sum 1 + 14 = 15. (1,5,6 is another increasing subsequence but its sum, 1 + 5 + 6 = 12 is smaller.)
Input specification: the first line contains n and the second line contains a1,…,an. Numbers on the same line are separated by spaces. You may assume that n is not bigger than 10, 000 and all the numbers fit in int.
Output specification: the output contains the maximum possible sum of an increasing subsequence (note: you do not have to compute the subsequence itself, just the maximum possible sum).
Perfect Social Moral Code GuidesorSubmit my paper for examination Endless supply of the perfect social good code, inside one sentence, it would be: be productive, not dangerous. We have numerous heavenly books, manuals on living, and self improvement tomes. Be that as it may, I feel this is the most demanding good code as far as a social setting. By social setting, I mean how we collaborate with others and act in social circumstances. However "be productive, not dangerous" sounds reasonable, there are numerous subtleties. Now and again it is hard to decide whether a demonstration is actually productive or dangerous. In the accompanying sections, these subtleties will be talked about in detail. We can choose if something is valuable or dangerous dependent on degree, for example. State your little child is misbehaving and broke a glass container, much after you advised him to quit snatching and playing with it a few times. You get an idea in your psyche to hit him to give a discipline for his underhanded activity. Be that as it may, you begin to feel befuddled about whether this would be helpful or ruinous. It may give him that not tuning in to you and breaking delicate things isn't welcome, however then again, punishing him is a demonstration of hostility that will hurt him genuinely and maybe instruct him to utilize power in circumstances sometime down the road. There is no accurate off-base or right around these times. In any case, through your own thinking, you can choose to what degree it would be gainful or hurtful to him and the current circumstance. By and by, I would not beat my child, as I figure it accomplishes more demolition than development. In any case, that is simply me. Another subtlety to consider is the definition we provide for development and demolition. For instance, for certain individuals, development can never include brutality, while for other people, it could even be an essential piece of the condition. Take the case of returning in time and killing Hitler. Slaughtering somebody is unquestionably named a dangerous demonstration. Nonetheless, considering the conditions, I would accept that most of individuals would concur that executing Hitler at the tallness of his capacity in the event that they got the opportunity would be viewed as a valuable, in this way positive act. Accordingly, our definitions regularly decide our qualities and how we act upon those standards. Moreover, development and decimation can be sifted through a sociopoltical focal point. Development can be viewed as acceptable to a few, and awful to other people. Take for example making new homes in a forested zone. Indeed, homes for people are made, yet in addition the territory for incalculable creatures is being annihilated, or possibly adjusted to an extraordinary. Development, on the off chance that it is valid, it ought to be advantageous to all gatherings included. That is a difficult task, however. Each progression we take eliminates microbes and different microorganisms—and maybe plants, creepy crawlies, and who recognizes what else. Decimation can be viewed as a piece of every second. Additionally, what a lion's share may see as a helpful may be viewed as damaging to a minority. Is there an approach to figure out which side is right? It is practically inconceivable. Being in the dominant part as far as an ethical standpoint doesn't mean it is right, or progressively suitable. There have been numerous examples in history when acts were seen as helpful, yet were later observed as dangerous with an advanced focal point. The Crusades, a progression of strict wars between essentially Christians and Muslims, were seen truly in an ideal light in its time by Christians. In any case, in the last 50% of the Crusades, conclusion about these heavenly wars were not lively among the Christian unwavering. What's more, in the event that one discussions about the current view on the Crusades, most of Christians will concede that it is a stain in their history books. Thus, regularly history isn't thoughtful to the discernments we once held. Despite the fact that I consider "Be valuable, not ruinous" the most strong one-sentence social good code, it not without its subtleties and problems. For example, how much we think about something productive or ruinous, meanings of being valuable and dangerous, and development and annihilation seen through a sociopolitical focal point are for the most part subtleties. These errors contain the disarray that this perfect social good code causes. Be that as it may, I can't envision a superior code than the one expressed in this paper as far as carrying on with one's life in a social setting.>GET ANSWER