//Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
// same ids are connected.
// prefix 的格式要求是 acm-[一级标题编号].[二级标题编号][该代码片段的英文简称]
// description 的格式要求是 "插入 [该代码片段的中文名]"

{
    "超哥线段树": {
        "prefix": "acm-2.6Blue Mary开公司",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#define LD double",
            "#define LL long long",
            "#define Re register int",
            "using namespace std;",
            "const int N=1e5+3,M=5e4;",
            "int n,x,T;LD b[N],k[N];char s[20];",
            "inline void in(Re &x){",
            "    int f=0;x=0;char c=getchar();",
            "    while(c<'0'||c>'9')f|=c=='-',c=getchar();",
            "    while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();",
            "    x=f?-x:x;",
            "}",
            "inline LD y(Re id,Re x){return k[id]*x+b[id];}",
            "struct Segment_Tree{",
            "\t#define pl (p<<1)",
            "\t#define pr (p<<1|1)",
            "\t#define mid ((L+R)>>1)",
            "\tint tr[N<<2];",
            "\tinline void change(Re p,Re L,Re R,Re id){",
            "\t\tif(y(id,L)>y(tr[p],L)&&y(id,R)>y(tr[p],R)){tr[p]=id;return;}",
            "\t\tif(y(id,L)<=y(tr[p],L)&&y(id,R)<=y(tr[p],R))return;",
            "//\t\tif(L==R){if(y(id,L)>y(tr[p],L))tr[p]=id;return;}",
            "\t\tif(k[tr[p]]<k[id]){",
            "\t\t\tif(y(id,mid+1)>y(tr[p],mid+1))change(pl,L,mid,tr[p]),tr[p]=id;",
            "\t\t\telse change(pr,mid+1,R,id);",
            "\t\t}",
            "\t\telse{",
            "\t\t\tif(y(id,mid)>y(tr[p],mid))change(pr,mid+1,R,tr[p]),tr[p]=id;",
            "\t\t\telse change(pl,L,mid,id);",
            "\t\t}",
            "\t}",
            "\tinline LD ask(Re p,Re L,Re R,Re x){",
            "\t\tif(L==R)return y(tr[p],x);",
            "\t\tLD ans=y(tr[p],x);",
            "\t\tif(x<=mid)return max(ans,ask(pl,L,mid,x));",
            "\t\telse return max(ans,ask(pr,mid+1,R,x));",
            "\t}",
            "}TR;",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tin(T);",
            "\twhile(T--){",
            "\t\tscanf(\"%s\",s);",
            "        if(s[0]=='P')++n,scanf(\"%lf%lf\",&b[n],&k[n]),TR.change(1,1,M,n);",
            "        else in(x),printf(\"%d\\n\",(int)(TR.ask(1,1,M,x-1)/100));",
            "\t}",
            "}",
            ""
        ],
        "description": "插入 超哥线段树"
    }
}