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 最近在筹备开一家自己的网络公司.由于他缺乏经济头脑,所以先后聘请了若干个金融顾问为他设计经营方案. 题目描述 万事开头难,经营公司更是如此.开始的收益往往是很低的,不过随 ...
随机推荐
- angularjs实现导航菜单切换高亮
<ul> <li ng-repeat="(index, item) in headerList"> <a ui-sref="{{item.h ...
- javaSe-反射3
package com.java.chap07.sec04; public class Student { private String name; private Integer age; publ ...
- LibreOJ #2003. 「SDOI2017」新生舞会
内存限制:256 MiB 时间限制:1500 ms 标准输入输出 题目类型:传统 评测方式:文本比较 上传者: 匿名 01分数规划(并不知道这是啥..) km或费用流(并不会)验证 屠龙宝刀点击就送 ...
- (转)SQL注入攻击简介
如果你是做Javaweb应用开发的,那么必须熟悉那声名狼藉的SQL注入式攻击.去年Sony就遭受了SQL注入攻击,被盗用了一些Sony play station(PS机)用户的数据.在SQL注入攻击里 ...
- spring security 2.x HttpSessionEventPublisher 以及listener配置
在环境为spring security2.x时 *JDK6 spring 2* 正确的filter路径是:org.springframework.security.ui.session.HttpSes ...
- 有关mybatis的动态sql
一般地,实现动态SQL都是在xml中使用等标签实现的. 我们在这里使用SQL构造器的方式, 即由abstract sql写出sql的过程, 当然感觉本质上还是一个StringBuilder, 来手动生 ...
- HDU - 5457 Hold Your Hand (Trie + 最小割)
Hold Your Hand Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 65535/102400 K (Java/Others)T ...
- 用Python计算最长公共子序列和最长公共子串
如何用Python计算最长公共子序列和最长公共子串 1. 什么是最长公共子序列?什么是最长公共子串? 1.1. 最长公共子序列(Longest-Common-Subsequences,LCS) 最长公 ...
- 剑指offer题目分类
1. 链表 1. 从尾到头打印链表 2. 链表中倒数第k个结点 3. 反转链表 4. 合并两个排序的链表 5. 复杂链表的复制 6. 复杂链表的复制 7. 两个链表的第一个公共结点 8. 链表中环的入 ...
- javaweb基础(23)_jsp自定义标签
一.自定义标签的作用 自定义标签主要用于移除Jsp页面中的java代码. 二.自定义标签开发和使用 2.1.自定义标签开发步骤 1.编写一个实现Tag接口的Java类(标签处理器类) 1 packag ...