Title: give you a degree of construction and height, we pray for the longest and descending heights.
Analysis: DP, maximum ascending sub.
Description: Has length and cannot directly optimize queue monotony.
#include <iostream> #include <cstdlib> #include <cstdio>using namespace Std;int h[2000],w[2000],u[ 2000],l[2000];int Main () {int t,n;while (~scanf ("%d", &t)) for (int T = 1; t <= t; + + t) {scanf ("%d", &n); t i = 0; I < n; + + i) scanf ("%d", &h[i]), for (int i = 0; i < n; + + i) scanf ("%d", &w[i]); int in = 0,de = 0;for (int i = 0; I &l T n; + + i) {u[i] = l[i] = w[i];for (int j = 0; J < i; + + j) {if (H[j] < H[i] && U[i] < U[j]+w[i]) u[i] = U[j] +w[i];if (H[j] > H[i] && l[i] < L[j]+w[i]) l[i] = L[j]+w[i];} if (in < u[i]) in = U[i];if (De < l[i]) de = l[i];} if (in >= de) printf ("Case%d. Increasing (%d)". Decreasing (%d). \ n ", T,in,de), Else printf (" Case%d. Decreasing (%d). Increasing (%d). \ n ", t,de,in);} return 0;}
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
UVa 11790-murcia& #39; s Skyline