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 ...
随机推荐
- anaconda 安装caffe,cntk,theano-未整理
一,anancona 安装 https://repo.anaconda.com/archive/ conda create -n caffe_gpu -c defaults python=3.6 ca ...
- ps -aux显示信息COMMAND不全
ps -aux结果: ps -auxwww结果:
- js怎么上传文件夹
1 背景 用户本地有一份txt或者csv文件,无论是从业务数据库导出.还是其他途径获取,当需要使用蚂蚁的大数据分析工具进行数据加工.挖掘和共创应用的时候,首先要将本地文件上传至ODPS,普通的小文件通 ...
- D5000系统使用手册--AVC
有关概念: AVC:自动电压控制 PAS:网络分析应用 SCADA:电网稳态监控应用 闭环:AVC由SCADA系统获得电网的实时运行状态,分析计算后发出控制指令,电网运行状态变化后反馈回AVC,形成闭 ...
- DVWA--XSS(反射型)
0X01爱之初介绍 虽然XSS已经做了两节了 但是还是还是简单解释一下 前言:跨站脚本(Cross-Site Scripting,XSS)是一种经常出现在Web应用程序中的计算机安全漏洞,是由于Web ...
- sqli-labs(18)
开始挑战第十八关(Header Injection - Uagent field - Error based) 常见的HTTP注入点产生位置为[Referer].[X-Forwarded-For].[ ...
- Windows10系统内置Linux
主要是在等电脑安装系统,有点慢,于是写个博客…… 还是那句话,从今年开始NOIP应该就不让用Windows了,所以还是尽早转Linux吧,不然NOIP考场上不会编译太尴尬对吧. 在学校电脑有Linux ...
- JavaScript DOM位置尺寸API
我们需要了解几个基础概念,每个HTML元素都有下列属性 offsetWidth clientWidth scrollWidth offsetHeight clientHeight scrollHeig ...
- linux测试某进程占用oi、cpu、内存的使用情况
pidstat 概述 pidstat是sysstat工具的一个命令,用于监控全部或指定进程的cpu.内存.线程.设备IO等系统资源的占用情况.pidstat首次运行时显示自系统启动开始的各项统计信息, ...
- ls -i
ls的不同选项有不同的含义: -l 是用long的长格式显示 条目信息 -a 显示所有的文件, 包括隐藏文件 -i: 是显示inode, 主要是用来查看硬链接的