#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
struct Node
{
char t;
int f;
double p;
int s;
}node[5010];
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int num=0,bn=0,sn=0;
vector<double> price;
string type;
double p;
int s,id;
while(cin>>type)
{
num++;
if(type!="cancel")
{
cin>>p>>s;
price.push_back(p);
node[num].f=1;
node[num].t= type=="buy" ? 'b':'s';
node[num].p=p;
node[num].s=s;
}
else
{
cin>>id;
node[id].f=0;
}
}
sort(price.begin(),price.end());
double pri=-1.00;
ll res=0;
for(int i=0;i<price.size();i++)
{
double cnt=price[i];
ll tmp1=0,tmp2=0;
for(int j=1;j<=num;j++)
{
if(node[j].f==1)
{
if(node[j].p>=cnt && node[j].t=='b') tmp1+=node[j].s;
if(node[j].p<=cnt && node[j].t=='s') tmp2+=node[j].s;
}
}
ll tmp=min(tmp1,tmp2);
if(tmp>=res)
{
res=tmp;
pri=cnt;
}
}
cout<<setiosflags(ios::fixed)<<setprecision(2)<<pri<<" "<<res;
return 0;
}
CCF-CSP 201412-3 集合竞价
最新推荐文章于 2023-03-12 11:12:39 发布