unsolved question's solution
因为很懒,没有时间,只会口胡等等原因,所以有些题目就不打code了
$luogu:$
时间离散化,预处理一个区间$[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)$
$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:$
操作可离线,贡献可根据祖先递推。
dfs序+$multiset$维护动态虚树
插入新操作(节点)时,对与前驱后缀的$lca$分类讨论,取深度大的点。
该点与lca之间的这一段就是新加入的贡献。
unsolved question's solution的更多相关文章
- 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 ...
- 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 ...
- 66. Regular Expression Matching
Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' ...
- 319. Bulb Switcher——本质:迭代观察,然后找规律
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every ...
- 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 ...
- Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...
- leetcode Jump Game II python
@link http://www.cnblogs.com/zuoyuan/p/3781953.htmlGiven an array of non-negative integers, you are ...
- leetcode Combination Sum II python
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...
- 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 ...
随机推荐
- .NET面试题系列(十九)Socket网络异常类型
序言 资料 异常测试之Socket网络异常
- #419 Div2 Problem B Karen and Coffee (统计区间重叠部分 && 前缀和)
题目链接 :http://codeforces.com/contest/816/problem/B 题意 :给出 n 表示区间个数,限定值 k 以及问询次数 q,当一个数被大于或等于 k 个区间重复覆 ...
- string [线段树优化桶排]
题意大概是给你一个字符串,1e5次修改,每次给一个区间升序排列或降序排列,最后输出这个字符串; 其实是个挺裸的线段树优化题;但是我没有意识去结合桶排,扑该..... 首先 1.40分算法 O(NMlo ...
- Selenium 详解xpath定位
xpath定位在业界被戏称为元素定位的"屠龙宝刀",宝刀在手,武林我有.现在我们就来详解xpath定位方法. 一.xpath通过元素属性定位 xpath可以通过元素的属性来定位,如 ...
- 3D Computer Grapihcs Using OpenGL - 13 优化矩阵
上节说过矩阵是可以结合的,而且相乘是按照和应用顺序相反的顺序进行的.我们之前初始化translationMatrix和rotationMatrix的时候,第一个参数都是使用的一个初始矩阵 glm::m ...
- 【每日一包0005】arr-flatten
github地址:https://github.com/ABCDdouyae... arr-flatten 将多维数组展开成一维数组 文档地址:https://www.npmjs.com/packag ...
- SettingBar的点击事件拦截
接下来我们再来看另外一个案例,正如上面界面上显示的两个条目,车辆选择和始发地点选择,他们都有一个共同的特点就是都有共同的标题,内容和右剪头按钮,这种情况下我们都会把它封装成一个组合的自定义View来显 ...
- iOS 自定义一对UI表现相反的按钮
假如有一对按钮[重置][提交],要让他们的默认UI和点击的UI表现刚好相反 [提交]按钮,默认橙色,点击边框是橙色,字体是橙色,背景变白色 [重置]按钮,默认白色橙色,边框是橙色,点击字体是白色,背景 ...
- centos64位编译32位程序
test.c #include <stdio.h> int main() { printf("sizeof long is %d\n",sizeof(long)); ; ...
- LeetCode_509.斐波那契数
LeetCode-cn_509 509.斐波那契数 斐波那契数,通常用 F(n) 表示,形成的序列称为斐波那契数列.该数列由 0 和 1 开始,后面的每一项数字都是前面两项数字的和.也就是: F(0) ...