luogu2293 [JSOI2008]Blue Mary开公司
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开公司的更多相关文章
- 数据结构(线段树):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 最近在筹备开一家自己的网络公司.由于他缺乏经济头脑,所以先后聘请了若干个金融顾问为他设计经营方案. 题目描述 万事开头难,经营公司更是如此.开始的收益往往是很低的,不过随 ...
随机推荐
- Redis hash(哈希)
Redis hash可储存多个键值对,适合储存对象的属性. 1.hset key fieldName fileValue //hset即hash set,set这里是设置的意思.往hash中添加 ...
- 准备Kendo UI 开发环境
准备 首先你需要从 Telerik 网站下载试用版开发包,注意需要注册后才能下载. 下载后直接解压后包含下面几个文件和目录: ./examples – 示例. /js – minified 化后的 J ...
- Appium基础一:Appium概念
1.Appium介绍: Appium是一款开源跨平台(IOS和Android平台)支持多种开发语言(java.python等)进行测试Native/Web/Hybrid的Android/iOS App ...
- centos 离线安装 mysql 5.7
1 . 安装新版mysql前,需将系统自带的mariadb-lib卸载. rpm -qa|grep mariadb mariadb-libs--.el7.centos.x86_64 rpm -e -- ...
- gitlab api批量操作 批量添加用户
import os,time import requests,json # def downloadFile(name, url): # headers = {'Proxy-Connection': ...
- Countup.js:vue-countup-v2(npm)数字滚动插件
1.官方地址:http://inorganik.github.io/countUp.js/ 2.官方demo: 3.参数说明: params——start(开始数字).end(结束数字).decima ...
- 如果不需要,建议移除net standard类库中的Microsoft.NETCore.Portable.Compatibility
使用Microsoft.NETCore.Portable.Compatibility会破坏该类库在Mono和Xamarin平台的兼容性 可能导致的问题 provides a compile-time ...
- MVC批量上传文件(使用uploadify)
<script src="JS/jquery-1.8.3.js"></script> <script src="uploadify/jque ...
- topcpder SRM 664 div2 A,B,C BearCheats , BearPlays equalPiles , BearSorts (映射)
A题,熊孩子测视力,水题,题意就是判断一下两个数对应位不相同的数字有多少个. #include<bits/stdc++.h> using namespace std; class Bear ...
- HDU 5094 Maze (状压)
加一个维度,钥匙的状态,状压一下.n很小,钥匙也只有10个,bfs就好了. 忘了数组初始化.以后坚决不犯这种低级错误. #include<cstdio> #include<queue ...