题解:
method1:迭代器
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<algorithm>
#include<stack>
#include<list>
#include<map>
#define ERROR -1
#define TURE 1
#define OK 1
#define INF -99999999
typedef long long ll;
using namespace std;
list<pair<ll,ll> >p;
list<pair<ll,ll> >::iterator it;
ll n,c,u,v;
ll ans;
int main()
{
while(cin>>n&&n)
{
while(n--)
{
cin>>c>>u>>v;
pair<ll,ll>q(u,v);
if(c==1)
{
p.push_back(q);
}
else if(c==-1)
{
for(it=p.begin();it!=p.end();it++)
{
if(*it==q)
{
p.erase(it);
break;
}
}
}
else
{
ans=INF;
for(it=p.begin();it!=p.end();it++)
{
ans=max(ans,it->first*u+it->second*v);
}
cout<<ans<<endl;
}
}
p.clear();
}
}
method2:结构体
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<map>
#define ERROR -1
#define TURE 1
#define OK 1
#define INF -99999999
using namespace std;
struct DogC{
int kind;
long long x,y;
}p[50005];
int k=0,c,u,v;
long long ans;
int main()
{
int n;
while(cin>>n&&n)
{
int t=n;
k=0;
while(t--)
{
cin>>c>>u>>v;
if(c==1)
{
p[k].x=u;
p[k++].y=v;
}
else if(c==-1)
{
for(int i=0;i<k;i++)
{
if(p[i].x==u&&p[i].y==v)
{
p[i].x=p[i].y=0;
}
}
}
else
{
ans=INF;
for(int i=0;i<k;++i)
{
long long res=p[i].x*u+p[i].y*v;
if(res>ans)
ans=res;
}
cout<<ans<<endl;
}
}
}
}