「Poetize10」封印一击
首先必须离散化,然后差分可以算出在区间外且<a[i]的总得分,再差分一次可以算出每个点被区间覆盖了几次,然后就是统计了。
代码:
#include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> #include<algorithm> #include<iostream> #include<vector> #include<map> #include<set> #include<queue> #include<string> #define inf 1000000000 #define maxn 1000000
#define maxm 500+100 #define eps 1e-10 #define ll long long #define pa pair<int,int> #define for0(i,n) for(int i=0;i<=(n);i++) #define for1(i,n) for(int i=1;i<=(n);i++) #define for2(i,x,y) for(int i=(x);i<=(y);i++) #define for3(i,x,y) for(int i=(x);i>=(y);i--) #define mod 1000000007 using namespace std; inline int read() { int x=,f=;char ch=getchar(); while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();} while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();} return x*f; }
struct rec{ll x,y;}b[maxn];
ll n,a[maxn],s[][maxn],c[maxn];
inline bool cmp(rec a,rec b){return a.x<b.x;} int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); n=read();
for1(i,n)a[(i<<)-]=read(),a[i<<]=read();
for1(i,n<<)b[i].x=a[i],b[i].y=i;
sort(b+,b+*n+,cmp);
int tot=;
for1(i,n<<)
{
if(i==||b[i].x!=b[i-].x)tot++;
a[b[i].y]=tot;c[tot]=b[i].x;
}
for1(i,n)
{
int l=a[(i<<)-],r=a[i<<];
s[][]+=c[l];s[][l]-=c[l];
s[][l]++;s[][r+]--;
}
int ans=;
for1(i,tot+)
{
s[][i]+=s[][i-];s[][i]+=s[][i-];
if(s[][i]+s[][i]*c[i]>s[][ans]+s[][ans]*c[ans])ans=i;
}
printf("%lld %lld\n",c[ans],s[][ans]+s[][ans]*c[ans]);
return ; }
「Poetize10」封印一击的更多相关文章
- 【tyvj】P2065 「Poetize10」封印一击(贪心+线段树/差分)
http://new.tyvj.cn/p/2065 我就不说我很sb的用线段树来维护值...... 本机自测的时候想了老半天没想出怎么维护点在所有区间被多少区间包含的方法.最后一小时才想出来线段树(果 ...
- 「Poetize10」能量获取
描述 Description “封印大典启动,请出Nescafe魂珠!”随着 圣主applepi一声令下,圣剑护法rainbow和魔杖护法freda将Nescafe魂珠放置于封印台上.封印台是一个树形 ...
- 「译」JUnit 5 系列:条件测试
原文地址:http://blog.codefx.org/libraries/junit-5-conditions/ 原文日期:08, May, 2016 译文首发:Linesh 的博客:「译」JUni ...
- 「译」JUnit 5 系列:扩展模型(Extension Model)
原文地址:http://blog.codefx.org/design/architecture/junit-5-extension-model/ 原文日期:11, Apr, 2016 译文首发:Lin ...
- JavaScript OOP 之「创建对象」
工厂模式 工厂模式是软件工程领域一种广为人知的设计模式,这种模式抽象了创建具体对象的过程.工厂模式虽然解决了创建多个相似对象的问题,但却没有解决对象识别的问题. function createPers ...
- 「C++」理解智能指针
维基百科上面对于「智能指针」是这样描述的: 智能指针(英语:Smart pointer)是一种抽象的数据类型.在程序设计中,它通常是经由类型模板(class template)来实做,借由模板(tem ...
- 「JavaScript」四种跨域方式详解
超详细并且带 Demo 的 JavaScript 跨域指南来了! 本文基于你了解 JavaScript 的同源策略,并且了解使用跨域跨域的理由. 1. JSONP 首先要介绍的跨域方法必然是 JSON ...
- 「2014-5-31」Z-Stack - Modification of Zigbee Device Object for better network access management
写一份赏心悦目的工程文档,是很困难的事情.若想写得完善,不仅得用对工具(use the right tools),注重文笔,还得投入大把时间,真心是一件难度颇高的事情.但,若是真写好了,也是善莫大焉: ...
- 「2014-3-18」multi-pattern string match using aho-corasick
我是擅(倾)长(向)把一篇文章写成杂文的.毕竟,写博客记录生活点滴,比不得发 paper,要求字斟句酌八股结构到位:风格偏杂文一点,也是没人拒稿的.这么说来,arxiv 就好比是 paper 世界的博 ...
随机推荐
- android ContentProvider学习
1.ContentProvider提供位存储或获取数据提供了统一的接口. 2.使用ContentProvider可以在不同的应用程序之间共享数据. 3.Android为常见的一些数据提供了Conten ...
- [Javascript] Writing conventional commits with commitizen
Because semantic-release requires a specific message format, it's easier to follow this convention u ...
- [AngularJS] ng-if vs ng-show
ng-show: ng-show element will stay in dom, just added a ng-hide attr, so it won't show. ng-if: It ha ...
- Etcd学习(一)安装和.NETclient測试
Etcd是一个比較新的分布式协调框架,由CoreOS的开发团队开发,如今才仅仅到0.4.6版本号,还没公布1.0版本号 我看了一下GitHub上作者们的提交记录,如今应该还在如火如荼的开发以及改动Bu ...
- RT: TCP connection close
CLOSE is an operation meaning "I have no more data to send." The notion of closing a full- ...
- js获取当前url地址及参数
介绍:设置或获取对象指定的文件名或路径. window.location.pathname //返回 设置或获取整个 URL 为字符串. window.location.href 设置或获取与 URL ...
- Android(java)学习笔记242:多媒体之设置全屏的方法
在实际的应用程序开发中,我们有时需要把 Activity 设置成全屏显示,一般情况下,可以通过两种方式来设置全屏显示效果.其一,通过在代码中可以设置,其二,通过manifest配置文件来设置全屏. 其 ...
- noip 2013 华容道
/*双向bfs (得分和单项的一样多....)70*/ #include<iostream> #include<cstdio> #include<cstring> ...
- prim 堆优化+ kruskal 按秩优化
#include<iostream> #include<cstdio> #include<cstring> #include<queue> #defin ...
- C#中创建线程,创建带参数的线程
线程操作主要用到Thread类,他是定义在System.Threading.dll下.使用时需要添加这一个引用.该类提供给我们四个重载的构造函 构造函数定义: 无参数委托 [SecuritySafeC ...