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:
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:
模拟:
#include
#include
#include
#include
#include
#include
#include
int main()
{
int n, m, l, ans = ;
cin >> n >> m >> l;
vector
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 ;
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章