因为很懒,没有时间,只会口胡等等原因,所以有些题目就不打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. 通过 PHP 生成 XML

    如需使用 PHP 在服务器上生成 XML 响应,请使用下面的代码: <?php header("Content-type:text/xml"); echo "< ...

  2. FJOI2017 day2游记

    day0 早上复习了一下凸包,lct的板子,发现现在的我好菜鸡啊,做题基本上还得看题解,自己不是很能分析出来. 下午去看考场,在附中机房又写了一遍lct,然后a掉了文理分科完就回去了. 回家的路上走在 ...

  3. 【CF1252L】Road Construction(基环树,最大流)

    题意:给定一张n点n边无重边自环的无向图,刚开始每条边都没有被选择,每条边上有一个颜色集合,必须从中选择一种 有K个工人,每个工人有颜色a[i],需要把工人分配到与其颜色相同的边上 问是否能有一种使得 ...

  4. Java连接Oracle数据库常用方法

    JDBC的六大步骤: 注册驱动 获取连接 获取执行sql语句对象 执行sql语句 处理结果集 关闭资源 oracle URL: jdbc:oracle:thin:@localhost:1521:SID ...

  5. android intent调用系统camera

    利用android的camera通常有两种方式:利用intent调用系统的camera,或者结合surfaceview实现自己定制的camera.先分别对这两种方法说明如下: 一.使用系统自配的cam ...

  6. Java中的可变参数

    1.什么是可变参数 可变参数是JDK1.5的新特性,允许一个方式接受任意数量的参数 public static void main(String[] args) { print("a&quo ...

  7. 在xml文件中使用该控件

    <yf.changsha.com.view.MyTextView android:layout_width="match_parent" android:layout_hei ...

  8. ps - 按进程消耗内存多少排序

    https://www.cnblogs.com/JemBai/archive/2011/06/21/2086184.html https://www.cnblogs.com/jiqing9006/p/ ...

  9. ffmpeg精简编译

    项目上需要用到ffmpeg的接收功能,把rtp流转封装为ts吐udp组播流,不涉及编码,所以需要精简一下脚本如下: #!/bin/bash dir=$(pwd) echo $dir rm -rf $d ...

  10. maven 成长之路

    1配置maven 环境变量 新建系统变量 M2_HOME :E:\apache-maven-3.5.2 在系统变量 path中添加 E:\apache-maven-3.5.2\bin 运行 mvn - ...