debug了半天。。发现头文件错了 不就是C和C++混搭么,你一个判题的系统至于这样么,累觉不爱
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include <algorithm>
using namespace std;
#define maxn 5007
#define test 7
#define ll long long
class node
{
public:
double val;
ll num;
int flag;
}tmp[maxn],b[maxn],s[maxn];
bool cmp1(node x,node y)
{
if(x.val!=y.val) return x.val>y.val;
return x.num>y.num;
}
bool cmp2(node x,node y)
{
if(x.val!=y.val) return x.val<y.val;
return x.num>y.num;
}
int main()
{
char op[20];
int tes=0;
while(scanf("%s",op)!=EOF)
{
tes++;
double val;
ll num;
if(op[0]=='b'||op[0]=='s')
{
scanf("%lf%lld",&val,&num);
tmp[tes].val=val;tmp[tes].num=num;
tmp[tes].flag=(op[0]=='b')?2:1;
}
else if(op[0]=='c')
{
scanf("%lld",&num);
tmp[tes].num=num;
tmp[tes].flag=0;
}
//if(tes==test)break;
}
for(int i=1;i<=tes;i++)
{
if(tmp[i].flag==0)
{
int num=tmp[i].num;
tmp[num].flag=0;
}
}
int num1=0,num2=0;
for(int i=1;i<=tes;i++)
{
if(tmp[i].flag==0) continue;
if(tmp[i].flag==1) s[num1++]=tmp[i];
else if(tmp[i].flag==2) b[num2++]=tmp[i];
}
sort(b,b+num2,cmp1);
sort(s,s+num1,cmp2);
ll sum=0;
ll ans=-1;
double ret;
for(int i=0;i<num2;i++)
{
ll tmp=0;
sum+=b[i].num;
for(int j=0;j<num1;j++)
{
if(s[j].val>b[i].val) break;
tmp+=s[j].num;
}
if(ans==-1||ans<min(tmp,sum))
{
ans=min(tmp,sum);ret=b[i].val;
}
}
printf("%.2lf %lld\n",ret,ans);
return 0;
}