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. InputThe 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.OutputFor each operation in which t equals to 0, you should print the maximal deliciousness degree of the best candy for the dog.Sample Input6 1 2 1 1 1 2 1 1 1 0 2 1 -1 2 1 0 2 1 0Sample Output5 4
1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 /* 5 不知道为啥,用map过不了 6 也不#include <bits/stdc++.h> 7 using namespace std; 8 typedef long long ll; 9 /* 10 不知道为啥,用map过不了 11 也不知道为啥用ll 12 */ 13 const int maxn=500005; 14 struct Node 15 { 16 ll x,y; 17 ll num; 18 } node[maxn]; 19 int main() 20 { 21 ll n,t,x,y; 22 while(~scanf("%lld",&n)&&n) 23 { 24 int len=0; 25 for(int i=0; i<n; i++) 26 { 27 scanf("%lld%lld%lld",&t,&x,&y); 28 if(t==1) 29 { 30 node[len].x=x; 31 node[len].y=y; 32 node[len++].num=1; 33 } 34 else if(t==-1) 35 { 36 for(int j=0; j<len; j++) 37 if(node[j].x==x&&node[j].y==y) 38 { 39 node[j].num=0; 40 41 } 42 } 43 else 44 { 45 ll sum=-0x3f3f3f3f3f3f3f3f; 46 47 for(int j=0; j<len; j++) 48 if(node[j].num) 49 sum=max(sum,x*node[j].x+y*node[j].y); 50 printf("%lld\n",sum); 51 } 52 } 53 } 54 return 0; 55 } 56 57 */ 58 const int maxn=500005; 59 struct Node 60 { 61 ll x,y; 62 ll num; 63 } node[maxn]; 64 int main() 65 { 66 ll n,t,x,y; 67 while(~scanf("%lld",&n)&&n) 68 { 69 int len=0; 70 for(int i=0; i<n; i++) 71 { 72 scanf("%lld%lld%lld",&t,&x,&y); 73 if(t==1) 74 { 75 node[len].x=x; 76 node[len].y=y; 77 node[len++].num=1; 78 } 79 else if(t==-1) 80 { 81 for(int j=0; j<len; j++) 82 if(node[j].x==x&&node[j].y==y) 83 { 84 node[j].num=0; 85 86 } 87 } 88 else 89 { 90 ll sum=-0x3f3f3f3f3f3f3f3f; 91 92 for(int j=0; j<len; j++) 93 if(node[j].num) 94 sum=max(sum,x*node[j].x+y*node[j].y); 95 printf("%lld\n",sum); 96 } 97 } 98 } 99 return 0; 100 }
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.
InputThe 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.OutputFor 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