[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 最近在筹备开一家自己的网络公司.由于他缺乏经济头脑,所以先后聘请了若干个金融顾问为他设计经营方案. 题目描述 万事开头难,经营公司更是如此.开始的收益往往是很低的,不过随 ...
随机推荐
- 关于如何在mac系统上安装Git并在码市上建立项目
对Git一窍不通,为了在mac系统上安装Git,查了很多资料,走了很多弯路,一切搞定后发现其实很简单. 1.在https://brew.sh上按要求安装Homebrew. 2.在电脑终端键入brew ...
- 听翁恺老师mooc笔记(13)--类型定义和联合
typedef 虽然我们知道使用struct这个关键字定义一个结构类型,然后可以使用该结构类型定义变量.但是每次要使用的时候都需要带着struct这个关键字,那么如何摆脱这个关键字哪?C语言提供了一个 ...
- C语言函数嵌套调用作业
一.实验作业 1.1 PTA题目:6-4 十进制转换二进制 设计思路 如果n大于1 对n/2继续进行该函数运算 输出n%2的值 代码截图 调试问题 我第一次做的时候判断的边界条件是大于0继续进行运算, ...
- 设计模式NO.2
设计模式NO.2 本次博客内容为第二次设计模式的练习.根据老师的要求完成下列题目: 题目1 如果需要开发一个跨平台视频播放器,可以在不同操作系统平台(如Windows.Linux.UNIX等)上播放多 ...
- Git学习使用
1.注册码云并建立远程仓库 2.安装git 3.使用eclipse egit 推送以及克隆 建立本地仓库,成功后如图 推送项目至本地仓库与远程仓库 使用右键菜单team-share 选项,与仓库关联后 ...
- 关于GPUImage的导入
对于GPUImage的使用方面,GitHub上已经非常详细了,就不一一赘述了,但是对于项目的导入来说,最好的方式是 1.下载GPUImage并解压 2.打开压缩包后如图 3.打开终端,cd到此目录 4 ...
- python使用tesseract-ocr完成验证码识别(安装部分)
一.tesseract-ocr安装 Ubuntu版本: 1.tesseract-ocr安装 sudo apt-get install tesseract-ocr 2.pytesseract安装 sud ...
- Nagios监控的部署与配置
[安装Nagios] yum install -y httpd httpd-devel httpd-tools mysql mysql-devel mysql-server php php-devel ...
- 英语日常词汇:living-room、dining-room vs dining hall
hall 大厅 : living room起居室,客厅 : dining room餐厅.饭厅 dining room是家里的客厅,比较小啊,dining hall一般指酒店或宾馆啊什么的的大厅,宴客厅
- Mysql官方文档翻译系列-7.3.1 Establishing a Backup Policy
原文链接 (https://dev.mysql.com/doc/refman/5.7/en/backup-policy.html) 正文 To be useful, backups must be s ...