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 ...
随机推荐
- C# 获得对象的命名空间 ?.
A a = new A(); var t = a?.ToString(); //t = WebApplication1.Controllers.A //获得命名空间和类名 var t1 = (A)nu ...
- 实战build-react(二)-------引入Ant Design(增加)
https://blog.csdn.net/zhan_lijian/article/details/85271906(copy) 1.肯定参考facebook关于react官网咯 快速搭建 creat ...
- uiautomatorviewer报错 Error taking device screenshot: EOF
报以下错误 估计是端口冲突 解决方法: 1. netstat -ano | findstr 5037 查看占用5037端口的进程 2. taskkill /pid 10508 /f 杀掉此进程 3 ...
- [CSP-S模拟测试]:电压机制(图论+树上差分)
题目描述 科学家在“无限神机”($Infinity\ Machine$)找到一个奇怪的机制,这个机制有$N$个元件,有$M$条电线连接这些元件,所有元件都是连通的.两个元件之间可能有多条电线连接.科学 ...
- android图片的缩放、圆角处理
android中图片缩放方法有三种:1,bitmapFactory:2,bitmap+metrix:3,thumbUtil 方法一:bitmapFactory: public static Bitma ...
- SpringBoot 整合Shiro 一指禅
目标 了解ApacheShiro是什么,能做什么: 通过QuickStart 代码领会 Shiro的关键概念: 能基于SpringBoot 整合Shiro 实现URL安全访问: 掌握基于注解的方法,以 ...
- legend3---Homestead中Laravel项目502 Bad Gateway
legend3---Homestead中Laravel项目502 Bad Gateway 一.总结 一句话总结: 用查看错误日志的方法解决错误:(/var/log/nginx/.log) 1.home ...
- 搜索引擎算法研究专题七:Hilltop算法
搜索引擎算法研究专题七:Hilltop算法 2017年12月19日 ⁄ 搜索技术 ⁄ 共 1256字 ⁄ 字号 小 中 大 ⁄ 评论关闭 HillTop也是搜索引擎结果排序的专利,是Google工 ...
- Python的复制,浅拷贝和深拷贝
https://www.cnblogs.com/xueli/p/4952063.html 如果给一个变量赋值一个对象,那么新变量和原对象变量将会是同一个引用,其中一方改变,另一方也会改变. 该问题可以 ...
- element 库 date-picker 的 disabledDate 的坑
概述 今天使用 element 库的 date-picker 组件,使用日期范围,然后使用了 disabledDate 属性,把 2018 年 1 月和 2020 年 12 月之后的日期全部 disa ...