Bzoj 1568 [Jsoi2008]blue Mary opens company Super Brother Line Tree

Source: Internet
Author: User

[JSOI2008] Blue Mary Open Company time limit:15 Sec Memory limit:162 MB
submit:1808 solved:639
[Submit] [Status] [Discuss] 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 whole hundred dollars (in hundred units,

For example, if the maximum yield for the day is 210 or 290, the output should be 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
0HINT Solution: You can see a lot of the function, and then every time you ask for an X coordinate answer, super-brother line tree can be said to permanently mark the maintenance of the maximum value of each segment.

    

1#include <cstring>2#include <cstdio>3#include <algorithm>4#include <iostream>5#include <cmath>6#include <queue>7#include <map>8 9 #defineN 50007Ten #defineLS p<<1 One #defineRS P<<1|1 A using namespacestd; -InlineintRead () - { the     intx=0, f=1;CharCh=GetChar (); -      while(!isdigit (CH)) {if(ch=='-') f=-1; ch=GetChar ();} -      while(IsDigit (CH)) {x= (x<<1) + (x<<3) +ch-'0'; ch=GetChar ();} -     returnx*F; + } -  + intN,tot; A Doubleans; at inttr[n<<2]; - Charch[ -]; - structNode - { -     Doublek,b; -}a[n<<1]; in  - BOOLJudgeintXintYintt) to { +t--; -     returna[x].b+a[x].k*t>a[y].b+a[y].k*T; the } * voidInsintPintLintRintx) $ {Panax Notoginseng     if(l==R) -     { the         if(Judge (x,tr[p],l)) tr[p]=x; +         return; A     } the     intMid= (l+r) >>1; +     if(a[x].k>a[tr[p]].k) -     { $         if(Judge (X,tr[p],mid)) ins (Ls,l,mid,tr[p]), tr[p]=x; $         ElseINS (rs,mid+1, r,x); -     } -     Else the     { -         if(Judge (X,tr[p],mid)) ins (rs,mid+1, R,tr[p]), tr[p]=x;Wuyi         Elseins (ls,l,mid,x); the     } - } Wu voidQueryintPintLintRintx) - { AboutAns=max (ans,a[tr[p]].k* (x1)+a[tr[p]].b); $     if(L==R)return; -     intMid= (l+r) >>1; -     if(x<=mid) query (ls,l,mid,x); -     ElseQuery (rs,mid+1, r,x); A } + intMain () the { -n=read (); $      for(intI=1; i<=n;i++) the     { thescanf"%s", ch); the         if(ch[0]=='P') the         { -tot++; inscanf"%LF%LF",&a[tot].b,&a[tot].k); theIns1,1, N,tot); the         } About         Else the         { theans=0; Query (1,1, N,read ()); theprintf"%d\n",(int) ans/ -); +         } -     } the}

Bzoj 1568 [Jsoi2008]blue Mary opens company Super Brother Line Tree

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.