题目

分析

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

很容易想到设 \(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. 解决linux mint内置无线网卡失效问题

    前言 同学安装了linux mint,但是内置的无线网卡失效,只能通过有线网卡连接,经过查询得到不是缺少驱动的问题,是内核不支持 解决办法 sudo apt install linux-generic ...

  2. Python异步协程(asyncio详解)

    续上篇讲解yield from博客,上篇链接:https://www.cnblogs.com/Red-Sun/p/16889182.html PS:本博客是个人笔记分享,不需要扫码加群或必须关注什么的 ...

  3. 【大数据面试】Flink 01 概述:包含内容、层次架构、运行组件、部署模式、任务提交流程、任务调度概念、编程模型组成

    一.概述 1.介绍 对无界和有界数据流进行有状态计算的分布式引擎和框架,并可以使用高层API编写分布式任务,主要包括: DataSet API(批处理):静态数据抽象为分布式数据集,方便使用操作符进行 ...

  4. Mybatis-Plus 对 json 的存储使用支持

    Mybatis-Plus 对 json 的存储使用支持 场景分析: 随着数据库对字段类型支持的多元化,json 类型的存储已成为多场景高频使用的字段类型.而 MySql.postgrpSql 等都支持 ...

  5. 云原生架构(二)环境搭建(Mac上安装Docker+Kubernetes+Istio一条龙)

    一.背景 Istio 项目由 Google 和 IBM 的团队与 Lyft 的 Envoy 团队合作启动.它已经完全在 GitHub 上公开开发.目前已经是"Service Mesh服务网格 ...

  6. day05-功能实现04

    家居网购项目实现04 以下皆为部分代码,详见 https://github.com/liyuelian/furniture_mall.git 10.功能09-后台管理 删除家居 10.1需求分析/图解 ...

  7. Linux基础第一章 概述

    第一章 概述 1.1 前言 本章讨论系统的概念,从硬件.操作系统角度更加深刻的理解计算机系统,并快速浏览Linux系统提供的服务. 1.2 系统组成     1.3 操作系统和应用程序 操作系统这个词 ...

  8. 新款 c++ web framework 支持orm http/2

    c++ web framework很少, 随着c++ 热度升温,c++ 在人工智能 自然语言处理 加快应用. 最近一款国产 c++ web framework 问世 写业务速度跟脚步语言一样速度 自带 ...

  9. Amber22 安装过程miniconda报错处理

    最近在安装amber22时,使用其官方说明安装,但在安装miniconda这一步出错,致使amber22安装不成功! 报错如下: CondaFileIOError: '/home/lbm/amber2 ...

  10. [WPF]Win10便签软件

    项目地址 Github:项目地址 软件截图 项目中用到的技术和问题 [WPF]限制程序单例运行 [WPF]创建系统栏小图标 [WPF]程序随系统自启动 [WPF]xml序列化以及反序列化数据 [WPF ...