[JSOI2008]Blue Mary开公司
Description
Input
Output
Sample Input
Project 5.10200 0.65000
Project 2.76200 1.43000
Query 4
Query 2
Project 3.80200 1.17000
Query 2
Query 3
Query 1
Project 4.58200 0.91000
Project 5.36200 0.39000
Sample Output
0
0
0
0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
struct Line
{
double b,k;
}line,tree[];
char s[];
double ans;
int n,N=;
int i;
bool pd(Line a,Line b,double x)
{
return (a.k*(x-)+a.b>b.k*(x-)+b.b);
}
double cal(Line a,double x)
{
return a.k*(x-)+a.b;
}
void update(int rt,int l,int r,Line x)
{
if (l==r)
{
if (pd(x,tree[rt],l))
tree[rt]=x;
return;
}
int mid=(l+r)/;
if (x.k>tree[rt].k)
{
if (pd(x,tree[rt],mid)) update(rt<<,l,mid,tree[rt]),tree[rt]=x;
else update(rt<<|,mid+,r,x);
}
if (x.k<tree[rt].k)
{
if (pd(x,tree[rt],mid)) update(rt<<|,mid+,r,tree[rt]),tree[rt]=x;
else update(rt<<,l,mid,x);
}
}
double query(int rt,int l,int r,int x)
{
if (l==r)
{
return cal(tree[rt],l);
}
int mid=(l+r)/;
ans=max(ans,cal(tree[rt],x));
if (x<=mid) ans=max(ans,query(rt<<,l,mid,x));
else ans=max(ans,query(rt<<|,mid+,r,x));
return ans;
}
int main()
{int T;
cin>>n;
for (i=;i<=n;i++)
{
scanf("%s",s);
if (s[]=='P')
{
scanf("%lf%lf",&line.b,&line.k);
update(,,N,line);
}
else
{
scanf("%d",&T);
ans=;
ans=query(,,N,T);
printf("%d\n",(int)ans/);
}
}
}
[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千题计划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 ...
- [BZOJ 1568][JSOI2008]Blue Mary开公司
[BZOJ 1568][JSOI2008]Blue Mary开公司 题意 \(n\) 次操作, 维护一个一次函数集合 \(S\). 有两种操作: 给定 \(b\) 和 \(k\), 向 \(S\) 中 ...
- 【BZOJ1568】[JSOI2008]Blue Mary开公司 线段树
[BZOJ1568][JSOI2008]Blue Mary开公司 Description Input 第一行 :一个整数N ,表示方案和询问的总数. 接下来N行,每行开头一个单词“Query”或“P ...
- 1568: [JSOI2008]Blue Mary开公司
1568: [JSOI2008]Blue Mary开公司 题目描述 传送门 题目分析 简单分析可以发现就是不停给出了\(n\)条直线,要求每次给出一条直线后求出所有直线在横坐标为\(x\)时\(y\) ...
- bzoj 1568 [JSOI2008]Blue Mary开公司 超哥线段树
[JSOI2008]Blue Mary开公司 Time Limit: 15 Sec Memory Limit: 162 MBSubmit: 1808 Solved: 639[Submit][Sta ...
- 1568: [JSOI2008]Blue Mary开公司(超哥线段树)
1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec Memory Limit: 162 MBSubmit: 1198 Solved: 418 Descr ...
- [Luogu] P4254 [JSOI2008]Blue Mary开公司
题目背景 Blue Mary 最近在筹备开一家自己的网络公司.由于他缺乏经济头脑,所以先后聘请了若干个金融顾问为他设计经营方案. 题目描述 万事开头难,经营公司更是如此.开始的收益往往是很低的,不过随 ...
随机推荐
- 关于python中的operator.itemgetter()函数的用法
1. operator.itemgetter(num)函数 表示对对象的第num维数据进行操作获取. >>>import operator >>>a = [1, 2 ...
- mongodb 高级操作
聚合 aggregate 聚合(aggregate)主要用于计算数据,类似sql中的sum().avg() 语法 db.集合名称.aggregate([{管道:{表达式}}]) 管道 管道在Unix和 ...
- 在Eclipse中调用Algs4库
首先下载Eclipse,我选择的是Eclipse IDE for Java Developers64位版本,下载下来之后解压缩到喜欢的位置然后双击Eclipse.exe启动 然后开始新建项目,File ...
- Android广播发送失败
现在至今为止Android 8.0 不支持大部分广播收发 如果无法使用建议换至Android 7.0版本 且 minSdkVersion 24
- Spring中报"Could not resolve placeholder"的解决方案
除去properites文件路径错误.拼写错误外,出现"Could not resolve placeholder"很有可能是使用了多个PropertyPlaceholderCon ...
- Linux CentOS7.0 (03)安装验证 docker
一.安装docker 1.升级 Linux 的软件包和内核 sudo yum update 2.安装 docker (1) sudo yum install docker (2).验证docker安 ...
- OpenID Connect 是什么?
一.OpenID Connect的概念 1.OpenID Connect 是什么? OpenID Connect 是一套基于 OAuth 2.0 协议的轻量级规范,提供通过 API 进行身份交互的框架 ...
- python入门(5)使用文件编辑器编写代码并保存执行
python入门(5)使用文件编辑器编写代码并保存执行 两款文本编辑器: 一个是Sublime Text,免费使用,但是不付费会弹出提示框: 一个是Notepad++,免费使用,有中文界面: 请注意, ...
- 启动Eclipse时An internal error occurred during: "Initializing Java Tooling".错误
解决方法一 重置窗口布局: windows > perspective > reset perspective 解决方法二: 如果上述方法不好使,采用下面的这种方法: 删除workspac ...
- HTML mate标签
META标签分两大部分:HTTP标题信息(http-equiv)和页面描述信息(name). http-equiv http-equiv类似于HTTP的头部协议,它回应给浏览器一些有用的信息,以帮助正 ...