#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define f first
#define s second
#define endl "\n"
const int N = 2e5 + 5, mod = 1e9 + 7; //!
int t, d[N], a[N];
main() {
// ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int n, q;
cin >> n >> q;
for(int i = 1; i <= n; i++) {
cin >> a[i];
if(i > 2) {
d[i - 2] = a[i] - a[i - 2];
}
}
for(int i = 1; i <= q; i++) {
int t;
cin >> t;
if(t < 3) {
int l, r, s, c;
cin >> l >> r >> s >> c;
if(t == 1) {
for(int j = l; j <= r; j++) a[j] += (j - l) * c + s;
for(int j = l ; j <= r - 2; j++) {
d[j] += c * 2;
}
d[l - 1] += s + c;
if(l > 1)
d[l - 2] += s;
if(l < r)
d[r - 1] -= s + (r - l - 1) * c;
d[r] -= s + (r - l) * c;
}
else {
for(int j = l; j <= r; j++) a[j] = (j - l) * c + s;
for(int j = l; j <= r - 2; j++) {
d[j] = c * 2;
}
d[l - 1] = a[l + 1] - a[l - 1];
if(l >= 2)
d[l - 2] = a[l] - a[l - 2];
d[r - 1] = a[r + 1] - a[r - 1];
d[r] = a[r + 2] - a[r];
}
for(int i = 2; i <= n; i++) {
d[i - 2] = a[i] - a[i - 2];
}
continue;
}
int l, r;
cin >> l >> r;
int ans = 3;
ans = min(ans, r - l + 1);
for(int k = l; k < r - 1; k++) {
int j = k - 1;
while(j < r - 2 && d[k] == d[j + 1]) ++j;
ans = max(ans, j - k + 3);
k = j;
}
cout << ans << endl;
}
}
Compilation message
Progression.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
10 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
61 ms |
6716 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
62 ms |
6672 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
61 ms |
6720 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
62 ms |
6672 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
61 ms |
6716 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |