不能简单模拟(会超时) 运用一点小技巧 减少时间复杂度
#include <cstdio>
#include <cstring>
using namespace std;
int a[200010];
int cc[200010];
int main()
{
int t,n,m,tt;
scanf("%d",&t);
memset(cc, 0, sizeof(cc));
memset(a, 0 ,sizeof(a));
int top = 1;
double sum = 0;
while(t--)
{
scanf("%d",&tt);
if(tt == 1)
{
scanf("%d%d",&n,&m);
cc[n] += m;
sum += n*m;
}
else if(tt == 2)
{
scanf("%d",&n);
a[++top] = n;
sum += n;
}
else
{
cc[top-1] += cc[top];
sum -= (a[top]+cc[top]);
cc[top] = 0;
top--;
}
printf("%.6lf\n",sum/top);
}
}