ref好像叫什么李超线段树?……这篇不是太通用……

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int n, T, uu;
double sa, sb;
const double eps=1e-7;
char ss[15];
struct SGT{
double tagk[200005], tagx[200005];
void update(int o, int l, int r, double k, double x){
if(tagk[o]*l+tagx[o]<k*l+x && tagk[o]*r+tagx[o]<k*r+x){
tagk[o] = k;
tagx[o] = x;
}
else if(tagk[o]*l+tagx[o]<k*l+x || tagk[o]*r+tagx[o]<k*r+x){
int mid=(l+r)>>1;
int lson=o<<1;
int rson=lson|1;
update(lson, l, mid, k, x);
update(rson, mid+1, r, k, x);
}
}
double query(int o, int l, int r, int x){
double re=x*tagk[o]+tagx[o];
if(l==r) return re;
else{
int mid=(l+r)>>1;
int lson=o<<1;
int rson=lson|1;
if(x<=mid) return max(re, query(lson, l, mid, x));
else return max(re, query(rson, mid+1, r, x));
}
}
}sgt;
int main(){
cin>>n;
while(n--){
scanf("%s", ss);
if(ss[0]=='P'){
scanf("%lf %lf", &sa, &sb);
sgt.update(1, 1, 50000, sb, sa-sb);
}
else{
scanf("%d", &uu);
printf("%d\n", (int)floor(sgt.query(1, 1, 50000, uu)/100));
}
}
return 0;
}

luogu2293 [JSOI2008]Blue Mary开公司的更多相关文章

  1. 数据结构(线段树):BZOJ 1568 [JSOI2008]Blue Mary开公司

    1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 602  Solved: 214[Submit ...

  2. bzoj千题计划219:bzoj1568: [JSOI2008]Blue Mary开公司

    http://www.lydsy.com/JudgeOnline/problem.php?id=1568 写多了就觉着水了... #include<cstdio> #include< ...

  3. 【BZOJ1568】[JSOI2008]Blue Mary开公司(李超线段树)

    [BZOJ1568][JSOI2008]Blue Mary开公司(李超线段树) 题面 BZOJ 洛谷 题解 是模板题啊. #include<iostream> #include<cs ...

  4. [BZOJ 1568][JSOI2008]Blue Mary开公司

    [BZOJ 1568][JSOI2008]Blue Mary开公司 题意 \(n\) 次操作, 维护一个一次函数集合 \(S\). 有两种操作: 给定 \(b\) 和 \(k\), 向 \(S\) 中 ...

  5. 【BZOJ1568】[JSOI2008]Blue Mary开公司 线段树

    [BZOJ1568][JSOI2008]Blue Mary开公司 Description Input 第一行 :一个整数N ,表示方案和询问的总数.  接下来N行,每行开头一个单词“Query”或“P ...

  6. 1568: [JSOI2008]Blue Mary开公司

    1568: [JSOI2008]Blue Mary开公司 题目描述 传送门 题目分析 简单分析可以发现就是不停给出了\(n\)条直线,要求每次给出一条直线后求出所有直线在横坐标为\(x\)时\(y\) ...

  7. bzoj 1568 [JSOI2008]Blue Mary开公司 超哥线段树

    [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 1808  Solved: 639[Submit][Sta ...

  8. 1568: [JSOI2008]Blue Mary开公司(超哥线段树)

    1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 1198  Solved: 418 Descr ...

  9. [Luogu] P4254 [JSOI2008]Blue Mary开公司

    题目背景 Blue Mary 最近在筹备开一家自己的网络公司.由于他缺乏经济头脑,所以先后聘请了若干个金融顾问为他设计经营方案. 题目描述 万事开头难,经营公司更是如此.开始的收益往往是很低的,不过随 ...

随机推荐

  1. JAVA基础之基本类型包装类、System类、Math类、Arrays类及大数据运算

    个人理解: 为了方便运算及调用一些方法,我们需要将基本类型的数值转换为对象:不过转换的时候需要特别注意好它们的类型到底是什么,需要调用方法的类名是哪个!特别注意是Byte常量池的相关问题(==):gc ...

  2. Wrinkles should merely indicate where smiles have been.

    Wrinkles should merely indicate where smiles have been. 皱纹应该只是微笑留下的印记.

  3. C#中Image类与byte[]之间的转换

    //将image转化为二进制 public byte[] GetByteImage(Image img) { byte[] bt = null; if (!img.Equals(null)) { us ...

  4. WinForm 窗体API移动 API阴影

    窗体移动 //窗体移动API [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllI ...

  5. WisdomTool REST Client 下载 测试请求,生成api文档

    https://github.com/Wisdom-Projects/rest-client

  6. JavaScript_3_输出

    1. JavaScript通常用于操作HTML元素,可以使用getElementById(id)方法. JavaScript由Web浏览器来执行. 2. document.write()仅仅向文档输出 ...

  7. LeetCode Remove Linked List Elements 删除链表元素

    题意:移除链表中元素值为val的全部元素. 思路:算法复杂度肯定是O(n),那么就在追求更少代码和更少额外操作.我做不出来. /** * Definition for singly-linked li ...

  8. CoreData介绍

    http://blog.csdn.net/zh952016281/article/details/52105683 写在前面 在CoreData中有一些常用的类,称呼可能各不相同.所以这里先约定一些关 ...

  9. [神经网络]一步一步使用Mobile-Net完成视觉识别(五)

    1.环境配置 2.数据集获取 3.训练集获取 4.训练 5.调用测试训练结果 6.代码讲解 本文是第五篇,讲解如何调用测试训练结果. 上一篇中我们输出了训练的模型,这一篇中我们通过调用训练好的模型来完 ...

  10. jQuery如何获取选中单选按钮radio的值

    使用jquery获取radio的值,最重要的是掌握jquery选择器的使用,在一个表单中我们通常是要获取被选中的那个radio项的值,所以要加checked来筛选,比如有以下的一些radio项: 1. ...