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 ...
随机推荐
- AngularJS的目录结构
templates/ _login.html _feed.html app/ app.js controllers/ LoginController.js FeedController.js dire ...
- caffe 安装
安装caffe 拉取镜像 nvidia/cuda:9.0-cudnn7-devel-centos7 1,换源 安装https://blog.csdn.net/tuomen5867/article/de ...
- CodeForces 1200E Compress Words
\(C_n^m\)的typora,点了一下启用源代码模式就把我已经写好的博客弄没了,就给我留个标题,自动保存也只给我保存了个标题--\(C_n^m\),wdnmd Time limit 1000 ms ...
- python build-in function
目录(?)[-] absx alliterable anyiterable basestring binx boolx callableobject chri classmethodfunction ...
- 用flask进行web开发
经理管理一个餐厅,推出每天都有特色菜的营销模式.他想根据一周中的每一天有一种特色菜. 客人想知道当天的特色菜是什么.另外再添加一个介绍页面.bios路径下,显示餐厅主人,厨师,服务生的简介. pyth ...
- sqli-libs(7)
导出文件GET字符型注入 0x01介绍 导出到文件就是可以将查询结果导出到一个文件中,如常见的将一句话木马导出到一个php文件中,sqlmap中也有导出一句话和一个文件上传的页面 常用的语句是: s ...
- CentOS7修改计算机名!
https://www.cnblogs.com/acgpiano/p/4170546.html sudo hostnamectl set-hostname <host-name>
- 关于R语言中set.seed()
在r中取sample时候,经常会有set.seed(某数),经常看见取值很大,其实这里无论括号里取值是多少,想要上下两次取值一样,都需要在每次取值前输入同样的set.seed(某数),才能保证两次取值 ...
- Mac securecrt 破解版安装
破解一 1.先链接:https://pan.baidu.com/s/1-1nu4eRf7BmuLg5MtlCRvw 密码:30pq 默认下载到了当前用户的”下载”目录中 在”Finder”中 ...
- [论文笔记] Improving Head Pose Estimation with a Combined Loss and Bounding Box Margin Adjustment
Improving Head Pose Estimation with a Combined Loss and Bounding Box Margin Adjustment 简介 本文提出了一种网络结 ...