Alice's hair is growing by leaps and bounds. Maybe the cause of it is the excess of vitamins, or maybe it is some black magic...

To prevent this, Alice decided to go to the hairdresser. She wants for her hair length to be at most ll centimeters after haircut, where ll is her favorite number. Suppose, that the Alice's head is a straight line on which nn hairlines grow. Let's number them from 11 to nn. With one swing of the scissors the hairdresser can shorten all hairlines on any segment to the length ll, given that all hairlines on that segment had length strictly greater than ll. The hairdresser wants to complete his job as fast as possible, so he will make the least possible number of swings of scissors, since each swing of scissors takes one second.

Alice hasn't decided yet when she would go to the hairdresser, so she asked you to calculate how much time the haircut would take depending on the time she would go to the hairdresser. In particular, you need to process queries of two types:

  • 00 — Alice asks how much time the haircut would take if she would go to the hairdresser now.
  • 11 pp dd — pp-th hairline grows by dd centimeters.

Note, that in the request 00 Alice is interested in hypothetical scenario of taking a haircut now, so no hairlines change their length.

Input

The first line contains three integers nn, mm and ll (1≤n,m≤1000001≤n,m≤100000, 1≤l≤1091≤l≤109) — the number of hairlines, the number of requests and the favorite number of Alice.

The second line contains nn integers aiai (1≤ai≤1091≤ai≤109) — the initial lengths of all hairlines of Alice.

Each of the following mm lines contains a request in the format described in the statement.

The request description starts with an integer titi. If ti=0ti=0, then you need to find the time the haircut would take. Otherwise, ti=1ti=1 and in this moment one hairline grows. The rest of the line than contains two more integers: pipi and didi (1≤pi≤n1≤pi≤n, 1≤di≤1091≤di≤109) — the number of the hairline and the length it grows by.

Output

For each query of type 00 print the time the haircut would take.

Example
input

Copy
4 7 3
1 2 3 4
0
1 2 3
0
1 1 3
0
1 3 1
0
output

Copy
1
2
2
1
Note

Consider the first example:

  • Initially lengths of hairlines are equal to 1,2,3,41,2,3,4 and only 44-th hairline is longer l=3l=3, and hairdresser can cut it in 11 second.
  • Then Alice's second hairline grows, the lengths of hairlines are now equal to 1,5,3,41,5,3,4
  • Now haircut takes two seonds: two swings are required: for the 44-th hairline and for the 22-nd.
  • Then Alice's first hairline grows, the lengths of hairlines are now equal to 4,5,3,44,5,3,4
  • The haircut still takes two seconds: with one swing hairdresser can cut 44-th hairline and with one more swing cut the segment from 11-st to 22-nd hairline.
  • Then Alice's third hairline grows, the lengths of hairlines are now equal to 4,5,4,44,5,4,4
  • Now haircut takes only one second: with one swing it is possible to cut the segment from 11-st hairline to the 44-th.

模拟:

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
//#include <xfunctional>
#define ll long long
#define mod 998244353
using namespace std;
int dir[][] = { {,},{,-},{-,},{,} };
const long long inf = 0x7f7f7f7f7f7f7f7f;
const int INT = 0x3f3f3f3f; int main()
{
int n, m, l, ans = ;
cin >> n >> m >> l;
vector<int> a(n + );
for (int i = ; i <= n; i++)
{
cin >> a[i];
if (a[i] > l && (i + > n || a[i + ] <= l) && (i - < || a[i - ] <= l))
ans++;
}
while (m--)
{
int t;
cin >> t;
if (t)
{
int p, d;
cin >> p >> d;
if (a[p] <= l)
{
a[p] += d;
if (a[p] > l && (p + > n || a[p + ] <= l) && (p - < || a[p - ] <= l))
{
ans++;
}
if (a[p] > l && p + <= n && a[p + ] > l && p - >= && a[p - ] > l)
ans--;
}
}
else
{
cout << ans << endl;
}
}
return ;
}

Alice and Hairdresser的更多相关文章

  1. 【Mail.Ru Cup 2018 Round 2 B】 Alice and Hairdresser

    [链接] 我是链接,点我呀:) [题意] [题解] 因为只会增加. 所以. 一开始暴力算出来初始答案 每次改变一个点的话. 就只需要看看和他相邻的数字的值就好. 看看他们是不是大于l 分情况增加.减少 ...

  2. Mail.Ru Cup 2018 Round 2 B. Alice and Hairdresser (bitset<> or 其他)

    传送门 题意: 给出你序列 a,在序列 a 上执行两种操作: ① 0 :查询有多少连续的片段[L,...,R],满足 a[L,...,R] > l: ② 1 p d :将第 p 个数增加 d: ...

  3. Mail.Ru Cup 2018 Round 2 Solution

    A. Metro Solved. 题意: 有两条铁轨,都是单向的,一条是从左往右,一条是从右往左,Bob要从第一条轨道的第一个位置出发,Alice的位置处于第s个位置,有火车会行驶在铁轨上,一共有n个 ...

  4. (HDU 5558) 2015ACM/ICPC亚洲区合肥站---Alice's Classified Message(后缀数组)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5558 Problem Description Alice wants to send a classi ...

  5. 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob

    Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  6. bzoj4730: Alice和Bob又在玩游戏

    Description Alice和Bob在玩游戏.有n个节点,m条边(0<=m<=n-1),构成若干棵有根树,每棵树的根节点是该连通块内编号最 小的点.Alice和Bob轮流操作,每回合 ...

  7. Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...

  8. 阿里前端框架Alice是个不错的选择

    BootStrap虽然用户群体广大,其整体风格尽管有不少skin可选,但以国情来看还是不好看. 阿里开源的前端框架,个人觉得还是很不错,Alice处处透着支付宝中界面风格的气息,电商感挺强. 以下内容 ...

  9. poj 1698 Alice‘s Chance

    poj 1698  Alice's Chance 题目地址: http://poj.org/problem?id=1698 题意: 演员Alice ,面对n场电影,每场电影拍摄持续w周,每周特定几天拍 ...

随机推荐

  1. 内网学习之Kerberos协议

    学习了解kerberos协议,有助于我们后期理解黄金票据和白银票据的原理 kerberos协议 kerberos是一种由麻省理工大学提出的一种网络身份验证协议.旨在通过使用密钥加密技术为客户端/服务器 ...

  2. Python之write与writelines区别

    一.传入的参数类型要求不同: 1. file.write(str)需要传入一个字符串做为参数,否则会报错. write( "字符串") with open('20200222.tx ...

  3. postgresql开篇

    postgresql 作为官方号称的最先进的开源数据库,从今天(2020-1-19)起开始系统的学习一下,记录自己学习的点点滴滴.

  4. [APIO2018] New Home 新家 [线段树,multiset]

    线段树的每个点表示当前点的前驱,即这个颜色上一次出现的位置,这个玩意multiset随便写写就完了. 重要的是怎么查询答案,无解显然先判掉. 线段树上二分就可以了 #include <bits/ ...

  5. PHP0014:PHP操作文件

    查看源代码 用这种方式抓取网页,和原始网页一模一样. 数组不能用echo 将一个网页保存到本地html文件

  6. 关于map 的几种方式

    java为数据结构中的映射定义了一个接口java.util.Map;它有四个实现类,分别是==HashMap Hashtable LinkedHashMap 和TreeMap.== Map主要用于存储 ...

  7. php环境配置 wampserver 数据库无法连接

    开始接触php编程,最初级的选择了wampserver+phpstorm+notepad++.值得注意的有一下几点. 1.使用跳过不输入数据库密码登录数据库之后请及时修改数据库密码以及相关文件.否则在 ...

  8. 吴裕雄--天生自然HADOOP操作实验学习笔记:hdfs简单的shell命令

    实验目的 了解bin/hadoop脚本的原理 学会使用fs shell脚本进行基本操作 学习使用hadoop shell进行简单的统计计算 实验原理 1.hadoop的shell脚本 当hadoop集 ...

  9. linux安装Nginx 以及 keepalived 管理Nginx

    linux安装Nginx 1.1将Nginx素材内容上传到/usr/local目录(pcre,zlib,openssl,nginx)(注意:必须登录用对这个文件具有操作权限的) 1.2安装pcre库 ...

  10. Spring Event事件驱动

    Spring事件驱动模型,简单来说类似于Message-Queue消息队列中的Pub/Sub发布/订阅模式,也类似于Java设计模式中的观察者模式. 自定义事件 Spring的事件接口位于org.sp ...