决策单调性&斜率&单调队列优化DP

毒瘤DP,DP里面最难写的。

P1912

最经典题目了属于是。
其实就是一个决策单调性板子题,因为年代久远所以比较难码出来。
关键就是找准最优子结构,我觉得这种都可以划一个模型,数列优化模型,都这么搞;

P5504

马了个大寄吧子,这题真的是好题,直接帮我理解了什么是斜率优化。
别的不多说了,斜率优化真的理解了还是很简单的,改写了一下也不会令人难以理解;
斜率优化,怎么说,每个点当成是直线和当成是点的意义还是不同的;

LOJ2157

整体二分型的决策单调性DP;

#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <random>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define MAXN 500005
#define LL long long
#define ULL unsigned long long
#define DB double
#define lowbit(x) (-(x) & (x))
#define ENDL putchar('\n')
#define FI first
#define SE second
int xchar() {
   
    static const int maxn = 1000000;
    static char b[maxn];
    static int pos = 0, len = 0;

    if (pos == len)
        pos = 0, len = fread(b, 1, maxn, stdin);

    if (pos == len)
        return -1;

    return b[pos ++];
}
//#define getchar xchar
LL read() {
   
    LL f = 1, x = 0;
    int s = getchar();

    while (s < '0' || s > '9') {
   
        if (s < 0)
            return -1;

        if (s == '-')
            f = -f;

        s = getchar();
    }

    while (s >= '0' && s <= '9') {
   
        x = (x << 3) + (x << 1) + (s ^ 48)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值