因为很懒,没有时间,只会口胡等等原因,所以有些题目就不打code了

$luogu:$


P1973 [NOI2011]Noi嘉年华

时间离散化,预处理一个区间$[l,r]$内的最多活动个数$in[l][r]$

无限制:

设$f[i][j]$表示到第$i$个时间点,第一个会场开$j$个活动时,第二个会场的最大活动数量

$f[i][j]=max(f[k][j-in[k][i]],f[k][j]+in[k][i])$

有限制:

时间分成三段,上面的dp倒着跑一遍得出$g[i][j]$

枚举必须取区间$[l,r]$的最大贡献$h[l][r]$,再枚举左边取$x$个,右边取$y$个

$h[l][r]=min(x+in[l][r]+y,f[l][x]+g[r][y])$

注意到$x$递增时,$f[l][x]$递减。所以$g[r][y]$只能递增,即$y$必须递减,具有单调性

$y$用指针维护,复杂度降至$O(n^3)$


P3188 [HNOI2007]梦幻岛宝珠

$a,b$很小,考虑对$b$分层后合并求解。

设$f[i][j]$表示代价为$a*b^i$的物品,占用$j*b^i$空间,跑01背包

合并时,$f[i][j]$表示代价为$a*b^{0 \sim i}$的物品,占用$j*b^i+(w$&$(2^i-1))$($w$二进制下的前$i-1$位)的空间

$f[i][j]=max(f[i][j],f[i][j-k]+f[i-1][min(s[i-1],k*2+(m$&$2^{i-1})])$,$s[i]$为前$i$层物品体积和$/2^i$

因为$j$倒序枚举,此时$f[i][j-k]$还是指占用$(j-k)*b^i$的空间

答案即为$f[m][1]$,$m$为$W$的二进制位数


$others:$


hihocoder1954 : 压缩树 :

操作可离线,贡献可根据祖先递推。

dfs序+$multiset$维护动态虚树

插入新操作(节点)时,对与前驱后缀的$lca$分类讨论,取深度大的点。

该点与lca之间的这一段就是新加入的贡献。

unsolved question's solution的更多相关文章

  1. Convert a given Binary Tree to Doubly Linked List

    The question and solution are from: http://www.geeksforgeeks.org/convert-given-binary-tree-doubly-li ...

  2. A trip through the Graphics Pipeline 2011_12 Tessellation

    Welcome back! This time, we’ll look into what is perhaps the “poster boy” feature introduced with th ...

  3. 66. Regular Expression Matching

    Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' ...

  4. 319. Bulb Switcher——本质:迭代观察,然后找规律

    There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every ...

  5. 318. Maximum Product of Word Lengths ——本质:英文单词中字符是否出现可以用26bit的整数表示

    Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the tw ...

  6. Valid Parentheses

    Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...

  7. leetcode Jump Game II python

    @link http://www.cnblogs.com/zuoyuan/p/3781953.htmlGiven an array of non-negative integers, you are ...

  8. leetcode Combination Sum II python

    Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...

  9. Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2) D. Something with XOR Queries

    地址:http://codeforces.com/contest/872/problem/D 题目: D. Something with XOR Queries time limit per test ...

随机推荐

  1. Java 性能优化的55个细节(珍藏版)

    在Java程序中,性能问题的大部分原因并不在于Java语言,而是程序本身.养成良好的编码习惯非常重要,能够显著地提升程序性能. 1.尽量在合适的场合使用单例 使用单例可以减轻加载的负担,缩短加载的时间 ...

  2. 全方面了解和学习PHP框架 PHP培训教程

    PHP成为最流行的脚本语言有许多原因:灵活性,易用性等等.对于项目开发来说,我们通常需要一个PHP框架来代替程序员完成那些重复的部分.本文,兄弟连将对PHP框架进行全面解析. PHP框架是什么? PH ...

  3. Android图片优化指南

    图片作为内存消耗大户,一直是开发人员尝试优化的重点对象.Bitmap的内存从3.0以前的位于native,到后来改成jvm,再到8.0又改回到native.fresco花费很多精力在5.0系统之前把B ...

  4. sh_02_快速体验

    sh_02_快速体验 import sh_01_九九乘法表 sh_01_九九乘法表.multiple_table()

  5. JMS学习十(ActiveMQ支持的传输协议)

    ActiveMQ提供了一种连接机制,这种连接机制使用传输连接器(TransportConnector)实现客户端与代理(client - to - broker)之间的通信. 网络连接器(networ ...

  6. IO负载高来源定位pt-ioprofile

    1.使用top -d 1 查看%wa是否有等待IO完成的cpu时间,简单理解就是指cpu等待磁盘写入完成的时间:IO等待所占用的cpu时间的百分比,高过30%时IO压力高: 2.使用iostat -d ...

  7. OperationCenter Docker运行环境及其依赖启动脚本

    1.Portainer docker rm -f portainer docker run -d -p : --name portainer --restart always portainer/po ...

  8. [ros] ros入门记录

    ROS入门 半天入门ROS,总体感觉比较好理解,python写不用编译超级爽,学完ros去学电控去了. ros2比ros1好用,所以最终是学ros2. ros1 安装 添加源 > sudo sh ...

  9. Visual Studio Code - 代码提示使用 webpack alias 的模块

    使用 PathIntellisense 还是使用jsconfig.json? 使用 PathIntellisense 只能提示模块路径,并无法让 vs code 的 Intellisense 知道这个 ...

  10. 全局namespace与模块内的namespace

    declare global{ declare namespace xxx } 相当于 在一个js文件的顶级部分 declare namespace xxx 声明的都是全局的namespace, 如果 ...