因为很懒,没有时间,只会口胡等等原因,所以有些题目就不打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. 20180705 SSH,SSM

    1.数据源切换2.数据库SQL server 2008R23.Herbernate,MyBaits, 框架spring mvc hibernate mybatis maven 管理 登录 spring ...

  2. 7.28Assignment

    1.考试题(7.27) + 2.插头dp 4道题 0/4  before 18:00 3.cdq分治 2道题理解 0/2  before 21:00 4.点分治 2道题 0/2 before 7:00 ...

  3. 小程序的image图片显示

    最近接触到了一点小程序的东西,跟我们平常的HTML还真不太一样,这里我先大概讲一下图片的显示问题, 小程序的图片用的是<image><image/>标签,他默认的大小是宽300 ...

  4. CloudSim学习

    CloudSim CloudSim是墨尔本大学云计算和分布式系统实验室推出的云计算模拟软件.它可以使研究者规避实际部署的诸多不便(比如说资金缺乏等因素),在单机上即可实现对大规模云集群的模拟和相应算法 ...

  5. json 的简单应用

    今天做爬虫时的一点盲区 :字符串, 字典,写到同一个文件中.难以利用!比如这样的数据:str = “hi,budy. i like 52pojie!”dirt = {“陈墨”:["男&quo ...

  6. mac卸载jdk

    在本地gradle打包后,将war包部署到服务器,tomcat的localhost日志报这个错: 严重: Error configuring application listener of class ...

  7. Spring Boot教程(六)在springboot中验证表单信息

    构建工程 创建一个springboot工程,由于用到了 web .thymeleaf.validator.el,引入相应的起步依赖和依赖,代码清单如下: <dependencies> &l ...

  8. wannalfy 挑战赛8 F 白云的树(树形dp)

    链接:https://www.nowcoder.com/acm/contest/57/F 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 262144K,其他语言524288K 64b ...

  9. [BZOJ3990]:[SDOI2015]排序(搜索)

    题目传送门 题目描述 小A有一个1-${2}^{N}$的排列A[1..${2}^{N}$],他希望将A数组从小到大排序,小A可以执行的操作有N种,每种操作最多可以执行一次,对于所有的i(1≤i≤N), ...

  10. js中Array方法归类解析

    为什么要对Array方法进行归类解析 因为它常用,而且面试必问 改变原数组的方法 pop 删除并返回数组最后一个元素push 从末尾给数组添加元素,返回新数组length值reverse 颠倒数组元素 ...