Description
Input first line: An integer n that represents the total number of scenarios and queries. Next n lines, each line starts with a word "Query" or "Project". If the word is query, then an integer t is followed, indicating that Blue Mary asks for the maximum benefit of the T-day. If the word is Project, then two real s,p are followed, indicating the first day of the design of the proceeds s, and the next day more than the last day of earnings P. 1 <= N <= 100000 1 <= T <=50000 0 < P < 100,| S | <= 10^6 Tip: The volume of reading and writing data may be quite large, please note that players choose efficient way to read and write files. Output for each query, outputs an integer that represents the answer to the query and is accurate to the full hundred (in hundred units, for example: The maximum gain for the day is 210 or 290, should be output 2). Answer when no solution is asked to output 0Sample Input10
Project 5.10200 0.65000
Project 2.76200 1.43000
Query 4
Query 2
Project 3.80200 1.17000
Query 2
Query 3
Query 1
Project 4.58200 0.91000
Project 5.36200 0.39000Sample Output0
0
0
0
0
Li Chao Segment tree template problem
http://www.yhzq-blog.cc/%e6%9d%8e%e8%b6%85%e7%ba%bf%e6%ae%b5%e6%a0%91%e6%80%bb%e7%bb%93/
http://blog.csdn.net/clover_hxy/article/details/52503987
https://wenku.baidu.com/view/6735b8e29b89680203d825b7.html
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <algorithm>5#include <cmath>6 using namespacestd;7 struct Line8 {9 Doubleb,k;Ten}line,tree[400001]; One Chars[ One]; A Doubleans; - intn,n=50000; - inti; the BOOLPD (line A,line B,Doublex) - { - return(A.k* (x1) +a.b>b.k* (x1)+b.b); - } + DoubleCal (Line A,Doublex) - { + returna.k* (x1)+a.b; A } at voidUpdateintRtintLintr,line x) - { - if(l==R) - { - if(PD (X,TREE[RT],L)) -tree[rt]=x; in return; - } to intMid= (L+R)/2; + if(x.k>tree[rt].k) - { the if(PD (X,TREE[RT],MID)) Update (rt<<1, L,mid,tree[rt]), tree[rt]=x; * ElseUpdate (rt<<1|1, mid+1, r,x); $ }Panax Notoginseng if(x.k<tree[rt].k) - { the if(PD (X,TREE[RT],MID)) Update (rt<<1|1, mid+1, R,tree[rt]), tree[rt]=x; + ElseUpdate (rt<<1, l,mid,x); A } the } + DoubleQueryintRtintLintRintx) - { $ if(l==R) $ { - returncal (tree[rt],l); - } the intMid= (L+R)/2; -ans=Max (ans,cal (tree[rt],x));Wuyi if(X<=mid) Ans=max (Ans,query (rt<<1, l,mid,x)); the ElseAns=max (Ans,query (rt<<1|1, mid+1, r,x)); - returnans; Wu } - intMain () About{intT; $Cin>>N; - for(i=1; i<=n;i++) - { -scanf"%s", s); A if(s[0]=='P') + { thescanf"%LF%LF",&line.b,&line.k); -Update1,1, n,line); $ } the Else the { thescanf"%d",&T); theans=0; -Ans=query (1,1, n,t); inprintf"%d\n",(int) ans/ -); the } the } About}
[JSOI2008] Blue Mary opens the company