// UVa 11790 - Murcia's Skyline #include <iostream> #include <vector> #include <stdio.h> using namespace std; int main() { int tt; cin >> tt; for (int t = 1; t <= tt; t++) { int n; cin >> n; vector<int> h, w, inc, dec; for (int i = 0; i < n; i++) { int a; cin >> a; h.push_back(a); } for (int i = 0; i < n; i++) { int a; cin >> a; w.push_back(a); } int s1 = 0, s2 = 0; for (int i = 0; i < n; i++) { inc.push_back(0); dec.push_back(0); for (int j = 0; j < i; j++) { if (h[j] < h[i] && inc[j] > inc[i]) inc[i] = inc[j]; if (h[j] > h[i] && dec[j] > dec[i]) dec[i] = dec[j]; } inc[i] += w[i]; dec[i] += w[i]; if (inc[i] > s1) s1 = inc[i]; if (dec[i] > s2) s2 = dec[i]; } if (s1 >= s2) printf("Case %d. Increasing (%d). Decreasing (%d).\n", t, s1, s2); else printf("Case %d. Decreasing (%d). Increasing (%d).\n", t, s2, s1); } return 0; }
Monday, May 9, 2016
UVa 11790 - Murcia's Skyline
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment