1568: [JSOI2008]Blue Mary开公司
1568: [JSOI2008]Blue Mary开公司
题目描述
题目分析
简单分析可以发现就是不停给出了\(n\)条直线,要求每次给出一条直线后求出所有直线在横坐标为\(x\)时\(y\)的最大值。
李超树裸题。
不知道李超树的可以移步百度。
是代码呢
#include <bits/stdc++.h>
using namespace std;
#define ls rt<<1
#define rs rt<<1|1
#define mid ((l+r)/2)
const int MAXN=5e5+7;
int n,m,st[MAXN],tr[MAXN<<2];
double a[MAXN<<2],b[MAXN<<2];
char opt[20];
inline int pd(int x,int y,int pos){return a[x]+(pos-1)*b[x]>a[y]+(pos-1)*b[y];}
inline void change(int l,int r,int rt,int x){
if(l==r){
if(pd(x,tr[rt],l)) tr[rt]=x;
return;
}
if(b[x]>b[tr[rt]])
if(pd(x,tr[rt],mid)) change(l,mid,ls,tr[rt]),tr[rt]=x;
else change(mid+1,r,rs,x);
if(b[x]<b[tr[rt]])
if(pd(x,tr[rt],mid)) change(mid+1,r,rs,tr[rt]),tr[rt]=x;
else change(l,mid,ls,x);
}
inline double getans(int k,int x){return a[k]+(x-1)*b[k];}
inline double query(int l,int r,int rt,int x){
if(l==r) return getans(tr[rt],x);
double ans=getans(tr[rt],x);
if(x<=mid) ans=max(ans,query(l,mid,ls,x));
else ans=max(ans,query(mid+1,r,rs,x));
return ans;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%s",opt);
if(opt[0]=='P'){
++m; scanf("%lf%lf",&a[m],&b[m]);
change(1,500005,1,m);
} else {
int x;scanf("%d",&x);
printf("%d\n", (int)query(1,500005,1,x)/100);
}
}
}
1568: [JSOI2008]Blue Mary开公司的更多相关文章
- 数据结构(线段树):BZOJ 1568 [JSOI2008]Blue Mary开公司
1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec Memory Limit: 162 MBSubmit: 602 Solved: 214[Submit ...
- [BZOJ 1568][JSOI2008]Blue Mary开公司
[BZOJ 1568][JSOI2008]Blue Mary开公司 题意 \(n\) 次操作, 维护一个一次函数集合 \(S\). 有两种操作: 给定 \(b\) 和 \(k\), 向 \(S\) 中 ...
- 1568: [JSOI2008]Blue Mary开公司(超哥线段树)
1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec Memory Limit: 162 MBSubmit: 1198 Solved: 418 Descr ...
- bzoj 1568 [JSOI2008]Blue Mary开公司 超哥线段树
[JSOI2008]Blue Mary开公司 Time Limit: 15 Sec Memory Limit: 162 MBSubmit: 1808 Solved: 639[Submit][Sta ...
- BZOJ.1568.[JSOI2008]Blue Mary开公司(李超线段树)
题目链接 线段树每个节点记录\(f(mid)\)最大的直线(在\(mid\)处函数值最大的直线),称作优势线段(还是直线啊...无所谓了). 如果是在区间插入线段会影响\(O(\log n)\)个区间 ...
- bzoj千题计划219:bzoj1568: [JSOI2008]Blue Mary开公司
http://www.lydsy.com/JudgeOnline/problem.php?id=1568 写多了就觉着水了... #include<cstdio> #include< ...
- 【BZOJ1568】[JSOI2008]Blue Mary开公司(李超线段树)
[BZOJ1568][JSOI2008]Blue Mary开公司(李超线段树) 题面 BZOJ 洛谷 题解 是模板题啊. #include<iostream> #include<cs ...
- 【BZOJ1568】[JSOI2008]Blue Mary开公司 线段树
[BZOJ1568][JSOI2008]Blue Mary开公司 Description Input 第一行 :一个整数N ,表示方案和询问的总数. 接下来N行,每行开头一个单词“Query”或“P ...
- [Luogu] P4254 [JSOI2008]Blue Mary开公司
题目背景 Blue Mary 最近在筹备开一家自己的网络公司.由于他缺乏经济头脑,所以先后聘请了若干个金融顾问为他设计经营方案. 题目描述 万事开头难,经营公司更是如此.开始的收益往往是很低的,不过随 ...
随机推荐
- Ajax 常用资源
regular online:http://regex.larsolavtorvik.com/ json online:http://json.cn/ Prototype:http://prototy ...
- java基础03变量和基本数据类型
package cn.bdqn.test; /** * * @author 小豆腐 * * 变量:会变化的量?? * 一个数据在内存中存储空间的表示!在运行期间可以动态改变! * * 关键字:在jav ...
- centos7手动编译安装Libvirt常见问题
由于功能需要,体验了手动编译安装Libvrt,还是碰到了不少问题,这里总结如下仅限于centos7: 1.configure: error: You must install the pciacces ...
- mysql删除重复数据,保留最新的那一条
因为数据库没键外键,在关联查询的时候,会碰到查询条数多余数据库实际条数,这因为关联字段在表中有重复值而导致的. 解决方案: 1.数据库脚本删除重复数据,保留最新的一条 2.对关联字段增加唯一约束 例如 ...
- jQuery中this与$(this)的差别
jQuery中this与$(this)的差别 $("#textbox").hover( function() { this.title ...
- MySQLdb使用批量插入executemany方法插入mysql
python的MySQLdb库可以使用批量操作executemany,进行多行插入. 比如向user表(username,salt,pwd)插入数据,具体的sql语句如下: sql = 'INSERT ...
- PAT 1052 Linked List Sorting [一般]
1052 Linked List Sorting (25 分) A linked list consists of a series of structures, which are not nece ...
- rabbitmq报错type
TypeError: exchange_declare() got an unexpected keyword argument 'type' 原因应该为pika版本不同导致的用法不同,解决方法为把t ...
- vmware下安装centos7
下载vmware http://down-www.newasp.net/pcdown/big/wm_pro_14_win.rar 下载centos7 https://www.centos.org/do ...
- tensorflow(二)----线程队列与io操作
一.队列和线程 1.队列: 1).tf.FIFOQueue(capacity, dtypes, name='fifo_queue') 创建一个以先进先出的顺序对元素进行排队的队列 参数: capaci ...