Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
Quadratic Functions
Time Limit: 3000MSMemory Limit: 65536K
Total Submissions: 852Accepted: 182

Description

You are to process a sequence of M queries of two types:

  • Add a quadratic function f(x) = ax2 + bx + c into the plane.
  • Compute the global minimum value of all the quadratic functions at x: min{fi(x)}.

Input

The first line consists of one integer: M (number of queries). (2 ≤ M ≤ 106)
The next M lines contain queries. Each query can be either addition or computation.

  • I a b c : add a quadratic function into the plane. You can assume the coefficient of the linear term is the double of the quadratic term's.
  • Q x : compute the global minimum value of all the quadratic functions at x: min{fi(x)}. Before the query, there is at least a curve in the plane.

All numbers in the input file are integers, whose absolute values are no more than 106.

Output

For each computation query, print a line consisting of one integer which denotes the global minimum value. Assume the absolute values of the answers are no more than 2 × 109.

Sample Input

2
I 1 2 1
Q 1

Sample Output

4

Source

POJ Monthly--2007.10.06, Amber(hupo001)@POJ

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator