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
", (int)floor(sgt.query(1, 1, 50000, uu)/100));
}
}
return 0;
}