CodeForces 674C Levels and Regions】的更多相关文章

#include<bits/stdc++.h> using namespace std; const int maxn=2e5+5; int N,K,head,tair; int q[maxn]; double S[maxn],A[maxn],B[maxn],dp[maxn][55]; double calc(int i,int j,int k){return dp[k][j-1]+A[i]-A[k]-S[k]*(B[i]-B[k]);} double x(int k){return S[k]…
Levels and Regions 把dp方程列出来, 把所有东西拆成前缀的形式, 就能看出可以斜率优化啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, int&…
一.预备知识 \(tD/eD\) 问题:状态 t 维,决策 e 维.时间复杂度\(O(n^{e+t})\). 四边形不等式: 称代价函数 w 满足凸四边形不等式,当:\(w(a,c)+w(b,d)\le w(b,c)+w(a,d),\ a < b < c < d\) 如下所示,区间1.2对应的 w 之和 ≤ 3.4之和 \[ \underbrace {\overbrace {a \to \underbrace{b \to c}_3}^1 \to d }_4 \llap{\overbrac…
标 * 的是推荐阅读的部分 / 做的题目. 1. 动态 DP(DDP)算法简介 动态动态规划. 以 P4719 为例讲一讲 ddp: 1.1. 树剖解法 如果没有修改操作,那么可以设计出 DP 方案 \(f_{i,0/1}\) 分别表示不选(\(0\))/ 选(\(1\))点 \(i\) 的最大权值,那么有 \(f_{i,0}=\sum_{x\in S_i}\max(f_{x,0},f_{x,1}),f_{i,1}=v_i+\sum_{x\in S_i}f_{i,0}\). 如果加上修改操作,那…
http://codeforces.com/contest/526/problem/E 题意:给一个环,每个点有权值,每次给一个数B,求把这个环切割成若干部分,每个部分不超过B,至少要切成几块? #include<cstdio> #include<cmath> #include<iostream> #include<cstring> #include<algorithm> #define ll long long ll a[]; ],f[]; i…
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute…
B. Pyramid of Glasses 题目链接:http://codeforces.com/contest/676/problem/B Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to constr…
C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions. Anton has a…
题目链接: http://codeforces.com/problemset/problem/6/D D. Lizards and Basements 2 time limit per test2 secondsmemory limit per test64 megabytes 问题描述 This is simplified version of the problem used on the original contest. The original problem seems to hav…
题目链接:http://codeforces.com/contest/499 A. Watching a movie You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute of the movie. By pressing this button, you watch the current minute of…