惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
L
LangChain Blog
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
Y
Y Combinator Blog
月光博客
月光博客
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Fortinet All Blogs
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
小众软件
小众软件
H
Help Net Security
Last Week in AI
Last Week in AI
B
Blog RSS Feed
宝玉的分享
宝玉的分享
N
Netflix TechBlog - Medium
博客园 - 叶小钗
The GitHub Blog
The GitHub Blog

某岛

AtCoder Beginner Contest 409 Luogu P5325. 【模板】Min_25 筛 UOJ #188. 【UR #13】Sanrd AtCoder Beginner Contest 371 AtCoder Beginner Contest 369 RPGMaker 2k3 百科 OneShot 的考古 2024“开创拓芯”游戏创享节的相关记录 CJ 回来后的戒断反应 Luogu P10221. [省选联考 2024] 重塑时光 Luogu P5308 [COCI2018-2019#4] Akvizna wqs 二分 歌唱王国 Lean 相关 BZOJ 3153. Sone1 The 2023 ICPC World Finals Luxor 新巴别塔 Sora 的想象与思考 Facebook Hacker Cup 2023 Round 1 AtCoder Beginner Contest 322 LLaMA 2 相关 HuggingFace AI Game Jam ACL 2023 Trans 相关… Luogu P2053. [SCOI2007] 修车 Luogu P1933. [NOI2010] 旅行路线 Luogu P1954. [NOI2010] 航空管制 Luogu P2048. [NOI2010] 超级钢琴 Luogu P2046. [NOI2010] 海拔 Luogu P3227. [HNOI2013] 切糕
Luogu P1973. [NOI2011] NOI 嘉年华
2023-06-11 · via 某岛

O(n4) 暴力写的好是能过得。。。。

#include <lastweapon/io>
using namespace lastweapon;
const int N = 200 + 1, PN = N*2 + 1;
VI P; int L[N], R[N], s[PN][PN];
int pre[PN][N], suf[PN][N]; // 一边为 j,另一边至多
int f[PN][PN];
int n, pn;

int main() {

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif

    RD(n); REP(i, n) {
        RD(L[i], R[i]); R[i] += L[i];
        P.PB(L[i]); P.PB(R[i]);
    }
    UNQ(P); REP(i, n) {
        L[i] = LBD(P, L[i]);
        R[i] = LBD(P, R[i]) - 1;
        s[L[i]][R[i]] += 1;
    }

    pn = SZ(P)-1; FOR(len, 1, pn) REP(l, pn-len) {
        int r = l + len;
        s[l][r] += s[l+1][r] + s[l][r-1] - s[l+1][r-1];
    }

    REP(i, pn) pre[i][0] = s[0][i];
    REP(i, pn) suf[i][0] = s[i][pn-1];

    REP(i, pn) REP_1(j, s[0][i]) REP(k, i) checkMax(pre[i][j], max(j <= s[0][k] ? pre[k][j] + s[k+1][i] : 0, j >= s[k+1][i] ? pre[k][j-s[k+1][i]] : 0));
    DWN(i, pn, 0) REP_1(j, s[i][pn-1]) DWN(k, pn, i) checkMax(suf[i][j], max(j <= s[k+1][pn-1] ? s[i][k] + suf[k+1][j] : 0, j >= s[i][k] ? suf[k+1][j-s[i][k]] : 0));

    int z = 0; FOR(i, 0, s[0][pn-1]+1) checkMax(z, min(i, suf[0][i]));
    cout << z << endl;

    REP(i, pn) FOR(j, i, pn) {
        REP(x, s[0][i-1]+1) REP(y, s[j+1][pn-1] +1) {
            checkMax(f[i][j], min(x + s[i][j] + y, pre[i-1][x] + suf[j+1][y]));
        }
    }

    DWN(len, pn-1, 0) REP(l, pn-len) {
        int r = l + len;
        if (l) checkMax(f[l][r], f[l-1][r]);
        if (r != pn-1) checkMax(f[l][r], f[l][r+1]);
    }

    REP(i, n) cout << f[L[i]][R[i]] << endl;
}

Posted by xiaodao
Category: 日常