[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 最近在筹备开一家自己的网络公司.由于他缺乏经济头脑,所以先后聘请了若干个金融顾问为他设计经营方案. 题目描述 万事开头难,经营公司更是如此.开始的收益往往是很低的,不过随 ...
随机推荐
- JavaScript(第十天)【Function类型】
在ECMAScript中,Function(函数)类型实际上是对象.每个函数都是Function类型的实例,而且都与其他引用类型一样具有属性和方法.由于函数是对象,因此函数名实际上也是一个指向函数对象 ...
- 2018.3.29 div内容格式设置
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> ...
- [福大软工] W班 评测作业对应表
- 初谈Git(本机克隆项目远程仓库)
1. 码云注册与新建项目 注册并新建项目 2. Git安装并配置 安装 配置 3. clone项目 附:一些Git命令 git clone 拷贝并跟踪远程的master分支 git add 跟踪新文件 ...
- 为label或者textView添加placeHolder
Tip:使用textView的代理需要在头文件中加入: <UITextViewDelegate> h文件 @interface FeedbackViewController : UIVie ...
- ajax的四种type类型
1.GET请求会向数据库发索取数据的请求,从而来获取信息,该请求就像数据库的select操作一样,只是用来查询一下数据,不会修改.增加数据,不会影响资源的内容,即该请求不会产生副作用.无论进行多少次操 ...
- 我从业11年来遇到的最奇葩的raid0+1数据恢复经历
我是一名数据恢复工程师,从事数据恢复行业已经11年了,前几天接到一组4块盘SCSI RAID0+1的数据恢复,客户说做了两组raid1,现在raid状态里显示有3快盘offline.如果两组盘分别作r ...
- JAVA_SE基础——22.面向对象的概念
我写博客是为了提升自己和为了进入黑马程序员学习,还有分享些自己的心得给大家,希望能帮助大家学习JAVA. 我是自学的,如果写的有错误或者能更好的修改的请提出. 在这里我先引用下<think in ...
- LeetCode & Q169-Majority Element-Easy
Array Divide and Conquer Bit Manipulation Description: Given an array of size n, find the majority e ...
- SecureCRT 7.3注册机激活
SecureCRT是一款很好用的远程登陆管理工具 工具和注册机下载链接:http://pan.baidu.com/s/1jImWiMU 密码:0yox 以管理管运行keygen.exe(一定要以管理员 ...