题目

分析

很神奇的事情又发生了!!

很容易想到设 \(f_{i,j}\) 表示考虑前 \(i\) 个区间,已选 \(j\) 个区间且必选第 \(i\) 时能覆盖到的最多苹果数

转移 \(O(n)\) 很显然了

然后,就没了·····

什么?!!

实际上测试数据给的答案是不能不用凳子的!!!

于是悲剧了······

\(Code\)

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std; const int N = 1e6 + 5 , M = 205;
int n , m , h , k , ans , fi , s[N] , f[M][M];
struct node{
int l , r;
}g[M];
bool cmp(node a , node b){return a.l < b.l ? 1 : (a.l == b.l ? a.r < b.r : 0);} int main()
{
freopen("apple.in" , "r" , stdin);
freopen("apple.out" , "w" , stdout);
scanf("%d%d%d%d" , &n , &m , &h , &k);
int x , Mx = 0;
for(register int i = 1; i <= n; i++)
{
scanf("%d" , &x);
if (x == h) {fi++; continue;}
if (x < h) continue;
s[x - h]++;
}
for(register int i = 1; i <= m; i++)
scanf("%d%d" , &g[i].l , &g[i].r) , Mx = max(Mx , g[i].r);
sort(g + 1 , g + m + 1 , cmp);
memset(f , -0x3f3f , sizeof f);
for(register int i = 1; i <= Mx; i++) s[i] += s[i - 1];
for(register int i = 1; i <= m; i++)
{
f[i][0] = 0 , f[i][1] = s[g[i].r] - s[g[i].l - 1];
for(register int j = 2; j <= min(i , k); j++)
for(register int l = 1; l < i; l++)
{
if (f[l][j - 1] < 0) continue;
int sum = s[g[i].r];
if (g[l].r >= g[i].l) sum -= s[g[l].r];
else sum -= s[g[i].l - 1];
f[i][j] = max(f[i][j] , f[l][j - 1] + sum);
}
}
for(register int i = k; i <= m; i++) ans = max(ans , f[i][k]);
printf("%d" , ans);
}

JZOJ 5350. 【NOIP2017提高A组模拟9.7】陶陶摘苹果的更多相关文章

  1. JZOJ 【NOIP2017提高A组模拟9.14】捕老鼠

    JZOJ [NOIP2017提高A组模拟9.14]捕老鼠 题目 Description 为了加快社会主义现代化,建设新农村,农夫约(Farmer Jo)决定给农庄里的仓库灭灭鼠.于是,猫被农夫约派去捕 ...

  2. [JZOJ 100026] [NOIP2017提高A组模拟7.7] 图 解题报告 (倍增)

    题目链接: http://172.16.0.132/senior/#main/show/100026 题目: 有一个$n$个点$n$条边的有向图,每条边为$<i,f(i),w(i)>$,意 ...

  3. JZOJ 2020.10.6 【NOIP2017提高A组模拟9.7】陶陶摘苹果

    陶陶摘苹果 题目 Description Input Output Sample Input 10 5 110 3 100 200 150 140 129 134 167 198 200 111 0 ...

  4. 【NOIP2017提高A组模拟9.7】JZOJ 计数题

    [NOIP2017提高A组模拟9.7]JZOJ 计数题 题目 Description Input Output Sample Input 5 2 2 3 4 5 Sample Output 8 6 D ...

  5. JZOJ 100029. 【NOIP2017提高A组模拟7.8】陪审团

    100029. [NOIP2017提高A组模拟7.8]陪审团 Time Limits: 1000 ms  Memory Limits: 131072 KB  Detailed Limits   Got ...

  6. JZOJ 5328. 【NOIP2017提高A组模拟8.22】世界线

    5328. [NOIP2017提高A组模拟8.22]世界线 (File IO): input:worldline.in output:worldline.out Time Limits: 1500 m ...

  7. JZOJ 5329. 【NOIP2017提高A组模拟8.22】时间机器

    5329. [NOIP2017提高A组模拟8.22]时间机器 (File IO): input:machine.in output:machine.out Time Limits: 2000 ms M ...

  8. JZOJ 5307. 【NOIP2017提高A组模拟8.18】偷窃 (Standard IO)

    5307. [NOIP2017提高A组模拟8.18]偷窃 (Standard IO) Time Limits: 1000 ms Memory Limits: 262144 KB Description ...

  9. JZOJ 5286. 【NOIP2017提高A组模拟8.16】花花的森林 (Standard IO)

    5286. [NOIP2017提高A组模拟8.16]花花的森林 (Standard IO) Time Limits: 1000 ms Memory Limits: 131072 KB Descript ...

  10. JZOJ 5305. 【NOIP2017提高A组模拟8.18】C (Standard IO)

    5305. [NOIP2017提高A组模拟8.18]C (Standard IO) Time Limits: 1000 ms Memory Limits: 131072 KB Description ...

随机推荐

  1. error while loading shared libraries: libSM.so.6: cannot open shared object file: No such file or di

    前言 运行 ida软件报错, 但是我的系统中存在 libSM.so.6 解决办法 首先查看系统中的 libsm.so.6 ldconfig -p |grep -i libsm.so.6 输出: lib ...

  2. JavaEE课程复习1--数据库相关操作

    〇.本模块内容简介 30=(DB5+前端5+Web Core15+Project5) Junit.注解 MySQL.JDBC.JDBCUtils.c3p0.Druid连接池及工具类.JDBCTempl ...

  3. 异构混排在vivo互联网的技术实践

    作者:vivo 互联网算法团队- Shen Jiyi 本文根据沈技毅老师在"2022 vivo开发者大会"现场演讲内容整理而成. 混排层负责将多个异构队列的结果如广告.游戏.自然量 ...

  4. python 之定时任务(schedule)

    import schedule import time def job(): print("定时通报...") # 定义一个叫job的函数,函数的功能是打印'定时通报...' sc ...

  5. Generator(生成器),入门初基,Coroutine(原生协程),登峰造极,Python3.10并发异步编程async底层实现

    普遍意义上讲,生成器是一种特殊的迭代器,它可以在执行过程中暂停并在恢复执行时保留它的状态.而协程,则可以让一个函数在执行过程中暂停并在恢复执行时保留它的状态,在Python3.10中,原生协程的实现手 ...

  6. 模仿 vscode-server 把本地代码目录映射到外网

    目录 概述 分析 解决方案 准备一台VM 创建容器 SmartIDE 创建 直接使用 docker 创建 SSH 远程转发 内网穿透 ngrok frp 服务端 客户端 本文模仿 vscode-ser ...

  7. CH579(Cortex-M0)网络IAP升级介绍及问题解答--(持续更新) 网络升级

    CH579网络IAP升级的源码可以从码云(Gitee)上git clone下来. 码云地址:https://gitee.com/maji19971221/wch-ch57x 以下是一个朋友问的几个常见 ...

  8. Centos7下vim最新版本安装

    一直以来用的都是vim,因为之前都是系统自带的vim没有研究过怎么自己安装,今天趁着刚装完新系统,顺便装下vim. 同样vim也有两种安装方法: 一.yum安装,centos下安装软件最简单的方法了, ...

  9. 题解P3847 [TJOI2007]调整队形

    简要题意 给出一个长度为 \(n\) 的序列 \(A\),你需要执行下面的操作,将这个序列变成回文序列: 在序列左右侧或中间插入一个元素,元素数值任意. 删除一个元素. 更改一个元素的值. \(1 \ ...

  10. vue打包---放到服务器下(一个服务器多个项目需要配置路径),以及哈希模式和历史模式的不同配置方法

    哈希模式,好用,不需要服务器配合分配路径指向,自己单机就可以打开了 接下来上代码截图 接下来开始截图 历史模式 历史模式需要后端支持 打包后自己直接点击是打不开的 截图如下