题目大意:给一个建筑的序列,建筑用高度和宽度描述,找出按高度的LIS和LDS,最长XX子序列的长度按照序列中建筑的宽度和进行计算。

  其实就是带权的最长XX子序列问题,原来是按个数计算,每个数权都是1,现在有不同的权重。

 #include <cstdio>
#include <algorithm>
using namespace std;
#define MAXN 100000 int h[MAXN], w[MAXN], lis[MAXN], lds[MAXN]; int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
int T;
scanf("%d", &T);
for (int kase = ; kase <= T; kase++)
{
int n;
scanf("%d", &n);
for (int i = ; i < n; i++)
scanf("%d", &h[i]);
for (int i = ; i < n; i++)
scanf("%d", &w[i]);
for (int i = ; i < n; i++)
{
lis[i] = lds[i] = w[i];
for (int j = ; j < i; j++)
{
if (h[i] > h[j]) lis[i] = max(lis[i], lis[j]+w[i]);
if (h[i] < h[j]) lds[i] = max(lds[i], lds[j]+w[i]);
}
}
int a = , b = ;
for (int i = ; i < n; i++)
{
a = max(a, lis[i]);
b = max(b, lds[i]);
}
if (a >= b) printf("Case %d. Increasing (%d). Decreasing (%d).\n", kase, a, b);
else printf("Case %d. Decreasing (%d). Increasing (%d).\n", kase, b, a);
}
return ;
}

UVa 11790 - Murcia's Skyline的更多相关文章

  1. UVa 11790 - Murcia&#39;s Skyline

    称号:给你一个行长度的建设和高度,我们祈求最长的和下降的高度. 分析:dp,最大上升子. 说明:具有长度,不能直接优化队列单调. #include <iostream> #include ...

  2. UVA 1232 - SKYLINE(线段树)

    UVA 1232 - SKYLINE option=com_onlinejudge&Itemid=8&page=show_problem&category=502&pr ...

  3. UVa 105 - The Skyline Problem(利用判断,在于想法)

    题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...

  4. uva 105 - The Skyline Problem

    一.用数组储存该位置的最高点即可(图形的连续点离散化),注意左边界及右边界的情况: 注意:无论建筑物最左边是盖到哪里,你都得从1开始输出(输入输出都是integer,所以才能离散化): #includ ...

  5. .Uva&LA部分题目代码

    1.LA 5694 Adding New Machine 关键词:数据结构,线段树,扫描线(FIFO) #include <algorithm> #include <cstdio&g ...

  6. [LeetCode] The Skyline Problem 天际线问题

    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...

  7. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  8. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  9. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

随机推荐

  1. Universal-Image-Loader分析:

    Android-Universal-Image-Loader是一个开源的UI组件程序,该项目的目的是提供一个可重复使用的仪器为异步图像加载,缓存和显示.权限: <uses-permission ...

  2. Activity not started, its current task has been brought to the front的解决办法

    删除bin目录下所有文件,重新启动在试试

  3. Windows API 之 CreateFile

    Creates or opens a file or I/O device. The most commonly used I/O devices are as follows: file, file ...

  4. C# 经典入门15章 -TabControl

  5. ZF-关于海南的增删改需求

    ,) ,,) ,) '); select * from SYS_ORGAN where org_name = '区教体局' update sys_organ set org_name = '综合行政执 ...

  6. PKI 笔记

    PKI – Public Key Infrastructure , 通常翻译为公钥基础设施. PKI 安全平台提供的4个服务,来保证安全的数据,分别是: l  身份识别 l  数据保密 l  数据完整 ...

  7. SDAU课程练习--problemO(1014)

    题目描述 Before bridges were common, ferries were used to transport cars across rivers. River ferries, u ...

  8. Dojo和jQuery区别

    Dojo类似jQuery,且用法也差不多,但是Dojo属于重量级的框架,自带的表单验证,Grid,tree等控件. 在选择上,个人觉得轻量级的框架比较好,因为方便引入第三方的,有特色的库. 就像选择S ...

  9. Allegro PCB -如何做自定义焊盘

    1.如何创建自定义焊盘,比如这种形状的焊盘. (1).打开PCB Editor –>Allegro PCB Design ->New,在类型中选择Shape symbol,并输入名字,比如 ...

  10. Query插件之ajaxFileUpload使用方法——input.change()事件的时候实现文件上传

    点击下载 这是HTML <input id="uploadedfile" name="uploadedfile" type="file" ...