Description:

Far far away, there live a lot of dogs in the forest. Unlike other dogs, those dogs love candies much more than bones.

Every candy has two attributes: the sweetness degree p and the sourness degree q. Different dogs like different candies. A dog also has two attributes: the fondness degree for sweetness x and the fondness degree for sourness y. So the deliciousness degree of a candy for a dog is defined as p×x + q×y.

The dog king has a huge candy box. At first, the box is empty. The king can add candies to the box or take some candies from the box and eat them. There are always some dogs who want to know which candies in the box are the most delicious for them. Please help the king to answer their questions.

Input:

The input consists of at most 10 test cases. For each test case, the first line contains an integer n indicating that there are n candy box operations(1 <= n <= 50000).

The following n lines describe the n operations.

Each operation contains three integers t, x and y( 0 <= |x|, |y| <= 109). The first integer t may be -1, 0, or 1.

If t equals -1, it means that a candy in the box with sweetness degree x and sourness degree y is eaten by the dog king.

If t equals 1, it means that a candy with sweetness degree x and sourness degree y is added to the candy box.

If t equals 0, it means that a dog with sweetness fondness degree x and sourness fondness degree y wants to know the maximal deliciousness degree of the candies in the box for him.

It is guaranteed that every candy is unique in the box.

The input ends by n = 0.

Output:

For each operation in which t equals to 0, you should print the maximal deliciousness degree of the best candy for the dog.

Sample Input:

6
1 2 1
1 1 2
1 1 1
0 2 1
-1 2 1
0 2 1
0

Sample Output:

5
4

题目链接

这道题目的时间限制为30000ms,也就是30s,所以肯定是暴力模拟直接写,开一个vector结构体容器,t=-1 遍历删除第一个符号要求的结构体,t=1放入一个新结构体,t=0遍历计算 p x + q y p*x+q*y px+qy 求出最大值即可。

AC代码:

#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF = 0x3f3f3f3f;
const int maxn = 2e2+5;
const int mod = 1e9+7;
const double eps = 1e-8;
const double pi = asin(1.0)*2;
const double e = 2.718281828459;
void fre() {
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
}

struct candy {
	ll p, q;
};

vector<candy> vec;

int main() {
	//fre();
	ll n;
	while (cin >> n, n) {
		vec.clear();
		while (n--) {
			ll t, x, y;
			cin >> t >> x >> y;
			if (t == -1) {
				for (vector<candy>::iterator it = vec.begin(); it != vec.end(); ) {
					candy temp = *it;
					if (temp.p == x && temp.q == y) {
						vec.erase(it);
						break;
					}
					++it;
				}
			}
			else if (t == 1) {
				candy temp;
				temp.p = x;
				temp.q = y;
				vec.pb(temp);
			}
			else if (t == 0) {
				ll ans = -INF;
				for (auto it : vec) {
					ll temp = it.p * x + it.q * y;
					if (temp > ans) {
						ans = temp;
					}
				}
				cout << ans << endl;
			}
		}
	}
    return 0;
}