Quantcast
Viewing all articles
Browse latest Browse all 39796

a hard problem

Given N non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. It'easy. So you can inc some bar,but the sum of the height you inc no more than M. Now,maximize the answer. 1 <= N <= 1000 0 <= M <= 1000; 0 <= ai <= 1000

For example, n = 3,m = 0 A : [1 , 0 , 1] answer : 1 n = 3, m = 2 A : [1 , 0 , 1] answer : 2 (you can inc a[1] and a[3])


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>