#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 300'000 + 10;
int n, q;
int d[N];
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> q;
for (int i = 1; i <= n; ++i) cin >> d[i];
while (q--) {
int type; cin >> type;
if (type == 1) {
int l, r, s, c; cin >> l >> r >> s >> c;
for (int i = l; i <= r; ++i) d[i] += s + c * (i - l);
} else if (type == 2) {
int l, r, s, c; cin >> l >> r >> s >> c;
for (int i = l; i <= r; ++i) d[i] = s + c * (i - l);
} else {
int l, r; cin >> l >> r;
int answer = 0;
for (int i = l + 1, cur = 0; i < r; ++i) {
if (d[i] - d[i - 1] == d[i + 1] - d[i]) cur += 1;
else cur = 0;
answer = max(answer, cur);
}
cout << answer + (l == r ? 1 : 2) << "\n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |