title: Max sum in an array with constraints
body: <p>I have this problem , where given an array of positive numbers i have to find the maximum sum of elements such that no two adjacent elements are picked. The maximum has to be less than a certain given K. I tried thinking on the lines of the similar problem without the k , but i have failed so far.I have the following dp-ish soln for the latter problem</p>
  
  <pre><code>    int sum1,sum2 = 0;
      int sum = sum1 = a[0];
  
      for(int i=1; i&lt;n; i++)
      {
          sum = max(sum2 + a[i], sum1);
          sum2 = sum1;
          sum1 = sum;
      }
  </code></pre>
  
  <p>Could someone give me tips on how to proceed with my present problem??</p>