标签:acm codeforces
const int maxn = 51000; int h[maxn], n; int fun(int l, int r, int sub) { if (l > r) return 0; int Min = INF, id; FE(i, l, r) if (h[i] < Min) { Min = h[i]; id = i; } return min(r - l + 1, fun(l, id - 1, Min) + fun(id + 1, r, Min) + Min - sub); } int main() { while (~RI(n)) { FE(i, 1, n) RI(h[i]); cout << fun(1, n, 0) << endl; } return 0; }
Codeforces Round #256 (Div. 2)——Painting Fence,布布扣,bubuko.com
Codeforces Round #256 (Div. 2)——Painting Fence
标签:acm codeforces
原文地址:http://blog.csdn.net/wty__/article/details/37923547