Maximum Sum Subsequence

4

1 votes
Easy
Problem

Given an array of positive numbers, find the maximum sum of a subsequence with the constraint that no two numbers in the sequence should be adjacent in the array.

INPUT

First line contains two integers N denoting size of array

Next line contains N integers denoting elmenets of  array.

OUTPUT  

Output the maximum sum of array such that no two elements are adjacent.

 

CONSTRAINTS

1N105

1Ai106

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?