题不怎么难,按线段树的解法 就是延迟标记,更新 因为找错找了N久 记一篇吧

向下更新时把+=写成了= 还做在了2W组的数据上 那个错找得真费劲。。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<queue>
using namespace std;
#define N 200012
int n;
#define LL long long
LL s[N<<],lz[N<<];
void down(int w,int m)
{
if(lz[w])
{
s[w<<]+=lz[w]*(m-m/);
s[w<<|]+=lz[w]*(m/);
lz[w<<] += lz[w];
lz[w<<|]+=lz[w];
lz[w] = ;
}
}
void up(int w)
{
s[w] = s[w<<]+s[w<<|];
}
void update(int a,int b,int d,int l,int r,int w)
{
if(a<=l&&b>=r)
{
s[w]+=(r-l+)*d;
lz[w]+=d;
return ;
}
int m = (l+r)>>;
down(w,r-l+);
if(a<=m)
update(a,b,d,l,m,w<<);
if(b>m)
update(a,b,d,m+,r,w<<|);
up(w);
}
void set(int p,int d,int l,int r,int w)
{
if(l==r)
{
s[w] = d;
return ;
}
int m = (l+r)>>;
down(w,r-l+);
if(p>m)
set(p,d,m+,r,w<<|);
else
set(p,d,l,m,w<<);
up(w);
}
int main()
{ int i,t,x,y,g=;
cin>>n;
LL sum=;
for(i = ; i <= n ; i++)
{
cin>>t;
if(t==)
{
cin>>x>>y;
update(,min(g,x),y,,N-,);
sum = s[];
printf("%.6f\n",double(sum)/g);
}
else if(t==)
{
cin>>x;
set(g+,x,,N-,);
sum = s[];
g++;
printf("%.6f\n",double(sum)/g);
}
else
{
if(g>)
{
set(g,,,N-,);
g--;
sum = s[];
}
printf("%.6f\n",double(sum)/g);
}
}
return ;
}

Codeforces Round #174 (Div. 1)A的更多相关文章

  1. Codeforces Round #174 (Div. 1) B. Cow Program(dp + 记忆化)

    题目链接:http://codeforces.com/contest/283/problem/B 思路: dp[now][flag]表示现在在位置now,flag表示是接下来要做的步骤,然后根据题意记 ...

  2. Codeforces Round #174 (Div. 2)

    A. Cows and Primitive Roots 暴力. B. Cows and Poker Game 模拟. C. Cows and Sequence 线段树维护. D. Cow Progra ...

  3. Codeforces Round #174 (Div. 1 + Div. 2)

    A. Cows and Primitive Roots 暴力. B. Cows and Poker Game 模拟. C. Cows and Sequence 线段树维护. D. Cow Progra ...

  4. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  5. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  6. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  7. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  8. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  9. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

随机推荐

  1. 【转载】在程序中动态改变static text控件的caption值

    方法1,给STATIC控件取个名字叫IDC_STATICTITLE 然后在ClassWizard中设定一个控件变量给它叫m_statictitle 然后用m_statictitle.SetWindow ...

  2. C#简单windows服务

    因为做后台比较多,所以经常需要写一些后台服务.一般的流程是先创建一个服务项目,加入代码.然后打包一个安装程序或者直接用dos命令安装服务.下面是详细内容:    1. 创建windows服务项目.  ...

  3. Windows Live Writer安装失败错误解决方案

    初次使用博客园.看到官方推荐Windows Live Writer来写作博客.看着也不错.可以离线写作.不用担心浏览器突然卡卡卡,未响应的危险. Windows Live Writer是博客园推荐博客 ...

  4. ASP.NET登录控件延伸(个性化)

    既然由登录控件涉及到了Membership,那么就不得不提到用户个性化Profile对象.个性化允许为用户保存特定的个性化信息到数据库中,因此它不同于ASP.NET状态管理之处在于可以永久性保存这些信 ...

  5. css内边距与外边距的区别

    你真的了解margin吗?你知道margin有什么特性吗?你知道什么是垂直外边距合并?margin在块元素.内联元素中的区别?什么时候该用 padding而不是margin?你知道负margin吗?你 ...

  6. *args和**kw魔法参数

    学Python挺久了,现在才搞懂这个还是有点惭愧 *args:传入元组,无关键字 **kw:传入字典,有关键字 示例: *args **kw 一起使用时args的参数需在前:

  7. 使用PHP_UML生成代码的UML图

    在读别人代码的时候, 在没有详细文档的时候, 如何快速的看清整个代码的结构(类结构), 就成为了一个现实的问题. 今天我就介绍一种, 自动生成UML图的方法. 假设, 我有一个项目文件夹:laruen ...

  8. Microsoft SDK 中Sample案例之Amcap項目 的运行方法(转)

    http://blog.csdn.net/erick08/article/details/7194575 Microsoft  SDK 中Sample之Amcap 的运行方法      写这篇文章的由 ...

  9. [你必须知道的.NET]第三十四回,object成员,不见了!

    发布日期:2009.10.30 作者:Anytao © 2009 Anytao.com ,Anytao原创作品,转贴请注明作者和出处. 在.NET世界了,object是公认的造物主,其麾下的7大成员, ...

  10. hdu 4462(状态压缩)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4462 思路:由于数据不大,可以直接将所有的状态表示出来,然后枚举,判断能否将方格全部覆盖. http: ...