因为很懒,没有时间,只会口胡等等原因,所以有些题目就不打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. druid配置以及监控

    1.druid监控的功能: . 数据源 . SQL监控 对执行的MySQL语句进行记录,并记录执行时间.事务次数等 . SQL防火墙 对SQL进行预编译,并统计该条SQL的数据指标 . Web应用 对 ...

  2. Linux培训教程 linux系统下分割大文件的方法

    在linux中分割大文件,比如一个5gb日志文件,需要把它分成多个小文件,分割后以利于普通的文本编辑器读取. 有时,需要传输20gb的大文件,Linux培训 教程件到另一台服务器,也需要把它分割成多个 ...

  3. 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 ...

  4. 【技术分享:python 应用之二】解锁用 VSCode 写 python 的正确姿势

    之前一直用 notepad++ 作为编辑器,偶然发现了 VScode 便被它的颜值吸引.用过之后发现它启动快速,插件丰富,下载安装后几乎不用怎么配置就可以直接使用,而且还支持 markdown.当然, ...

  5. Android 内存泄漏优化总结

    1,验证是否为汉字 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 3 ...

  6. 启动Maven项目时报错Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project **-web: Failed to clean project: Failed to delete E:\**\target\tomcat\logs\access_lo

    这类错误 出现这种错误,通常是由于您已启动了另一个tomcat 进程或者运行的javaw.exe进程,导致报错. 解决方法: 1. 鼠标点击 X 进行关闭运行失败的 Console页,(如果运行多次, ...

  7. a标签点击,页面自动刷新

    <a href="javascript:void(0)" id="reDiagnosis" class="checkBtn"oncli ...

  8. php 判断字符串包含

    PHP语言是一个功能强大的嵌入式HTML脚本语言,它的易用性让许多程序员选择使用.PHP判断字符串的包含,可以使用PHP的内置函数 strstr,strpos,stristr直接进行判断.也可以通过e ...

  9. 【洛谷T89379 【qbxt】复读警告】

    题目链接 这个题可以应用dp #include<bits/stdc++.h> using namespace std; ; inline int read() { ,b=; char c= ...

  10. sql语句实现行转列的3种方法实例

    sql语句实现行转列的3种方法实例 一般在做数据统计的时候会用到行转列,假如要统计学生的成绩,数据库里查询出来的会是这样的,但这并不能达到想要的效果,所以要在查询的时候做一下处理,下面话不多说了,来一 ...