9079: Even

内存限制:512 MB 时间限制:2 S
题面:传统 评测方式:文本比较 上传者:
提交:3 通过:2

题目描述

You have an array of nnn elements a1, a2,…, ana_1, \ a_2, \dots , \ a_na1, a2,, an.

You need to answer qqq queries (each query is independent with others). Every query will give you l, r, kl, \ r, \ kl, r, k  and it can be completed by the following code: 

a[0] = 0;
bool have_even = 0;
for(int i = l; i <= r; i++)if (a[i] % 2 == 0 && a[i] > 0 ) have_even = 1;
if (have_even)
{
	index = 0;
	for(int i = l; i <= r; i++)
	{
		if (a[index] < a[i] && a[i] % 2 == 0) index = i;
	}
	a[index] /= 2; 
}else
{
	index = l;
	for(int i = l; i <= r; i++)
	{
		if (a[index] < a[i]) index = i;
   	}
	if (a[index] > 0) a[index] = (a[index] - 1) / 2;
}
You want to know the maximum value of interval [l, r][l, \ r][l, r] after kkk operations.

输入格式

The first line contains two positive integers n, qn, \ qn, q(1≤n≤104,1≤q≤1051\le n \le 10^4, 1\le q \le 10^51n104,1q105).
The second line contains nnn integers a1, a2,…, ana_1, \ a_2,  \dots, \ a_na1, a2,, an(1≤ai≤1091 \le a_i \le 10^91ai109) .
Each of the next qqq lines contains three integers l, r, kl,\ r,\ kl, r, k(1≤l≤r≤n,1≤k≤1091\le l\le r \le n, 1 \le k \le 10^91lrn,1k109) .

输出格式

For each test case, output the maximum number.

输入样例 复制

3 2
1 2 3
1 2 1
1 3 3

输出样例 复制

1
1