千里传送 题目ID:9256 WA60

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m1;
vector<pair<int, int> > q;
int a[200005], b[200005];
void f() {
	cin >> n >> m1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		q.push_back(make_pair(a[i] + min(i, n + 1 - i), i));
	}
	sort(q.begin(), q.end());
	for (int i = 0; i < q.size(); i++) {
		b[i + 1] = b[i] + q[i].first;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int m = m1,z = 0;
		if (m >= a[q[i - 1].second] + q[i - 1].second) {
			z = 1;
			m -= a[q[i - 1].second] + q[i - 1].second;
			int it = upper_bound(b + 1, b + i, m) - b - 1;
			z += it;
			m -= b[it];
			it = upper_bound(b + i + 1, b + 1 + n, m + b[i]) - b - 1;
			z += it - i;
		}
		ans = max(ans, z);
	}
	cout << ans << "\n";
}
signed main() {
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
  std::ios::sync_with_stdio(false);
std::cin.tie(0); 
std::cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		f();
	}
	return 0;
}