This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
using ll = long long;
const int mxn = 3e5+5;
int n, q;
ll D[mxn];
int main() {
cin >> n >> q;
for(int i = 1; i <= n; i++) cin >> D[i];
for(int i = 0; i < q; i++) {
ll t, l, r, s, c; cin >> t >> l >> r;
if(t == 1) {
cin >> s >> c;
for(int j = l; j <= r; j++) D[j] += s+(j-l)*c;
}
else if(t == 2) {
cin >> s >> c;
for(int j = l; j <= r; j++) D[j] = s+(j-l)*c;
}
else {
int ans = 1, diff = D[l+1]-D[l], cnt = 1;
for(int j = l+1; j <= r; j++) {
if(diff == D[j]-D[j-1]) {
cnt++; ans = max(ans, cnt);
}
else {
diff = D[j]-D[j-1], cnt = 2;
}
}
cout << ans << "\n";
}
}
return 0;
}
# | 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... |