博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
P2519 [HAOI2011]problem a
阅读量:4693 次
发布时间:2019-06-09

本文共 891 字,大约阅读时间需要 2 分钟。

把所有人按 $a_i$ 从小到大排序, $a_i$ 越小说明如果那个人说真话,分数越高

对于 $a_i$ 相同的人,如果 $b_i$ 不同那么最多只有一种 $b_i$ 是真的,所以考虑把 $a_i,b_i$ 相同的合并,价值为人数

进一步考虑,对于 $a_i$ 不同的人,他们同时说真话的条件是什么

不妨把这些人看成一个个区间,$a_i,b_i$ 的人所在的区间为 $[a_i+1,n-b_i]$,即在这一个区间的人分数要一样,如果两个不同的区间要同时合法,那么因为他们分数不同,所以两个区间不能有交集

现在题目就转化成了:若干个区间,每个区间有一个价值,取出若干不交的区间使得价值最大

然后按右端点排序,直接 $dp$ 即可

#include
#include
#include
#include
#include
using namespace std;typedef long long ll;inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); } return x*f;}const int N=2e5+7;int n,m;struct dat { int l,r,v; inline bool operator < (const dat &tmp) const { return l!=tmp.l ? l

 

转载于:https://www.cnblogs.com/LLTYYC/p/11475111.html

你可能感兴趣的文章
getTickCount()函数 VS GetTickCount()函数
查看>>
嵌入式jetty
查看>>
2017~回顾分享
查看>>
使用svn——项目的目录布局
查看>>
RSA System.Security.Cryptography.CryptographicException
查看>>
webservice整合spring cxf
查看>>
[解题报告] 100 - The 3n + 1 problem
查看>>
Entity Framework 学习高级篇1—改善EF代码的方法(上)
查看>>
Mybatis逆向工程配置文件详细介绍(转)
查看>>
String类的深入学习与理解
查看>>
不把DB放进容器的理由
查看>>
OnePage收集
查看>>
Java parseInt()方法
查看>>
yahoo的30条优化规则
查看>>
[CCF2015.09]题解
查看>>
[NYIST15]括号匹配(二)(区间dp)
查看>>
json_value.cpp : fatal error C1083: 无法打开编译器生成的文件:No such file or directory
查看>>
洛谷 P1101 单词方阵
查看>>
Swift DispatchQueue
查看>>
C#和JAVA 访问修饰符
查看>>