#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 3e5 + 10;
struct node
{
int left_val, right_val;
int left_len, right_len;
int longest;
node()
{
left_val = right_val = 0;
left_len = 0;
right_len = 0;
longest = 0;
}
};
int n, q;
ll d[maxn], b[maxn];
void solve()
{
cin >> n >> q;
for (int i = 1; i <= n; i ++)
cin >> d[i], b[i] = d[i] - d[i - 1];
for (int i = 1; i <= q; i ++)
{
int type, l, r, s, c;
cin >> type >> l >> r;
if (type == 1)
{
cin >> s >> c;
for (int j = l; j <= r; j ++)
{
d[j] += s + (j - l) * c;
b[j] += c;
}
b[l] = d[l] - d[l - 1];
b[r + 1] = d[r + 1] - d[r];
}
else
if (type == 2)
{
cin >> s >> c;
for (int j = l; j <= r; j ++)
{
d[j] = s + (j - l) * c;
b[j] = c;
}
b[l] = d[l] - d[l - 1];
b[r + 1] = d[r + 1] - d[r];
}
else
{
if (l == r)
{
cout << 1 << endl;
continue;
}
int len = 1, ans = 0;
for (int j = l + 2; j <= r; j ++)
{
if (b[j] == b[j - 1])
len ++;
else
{
ans = max(ans, len);
len = 1;
}
}
ans = max(ans, len);
cout << ans + 1 << endl;
}
/**for (int j = 1; j <= n; j ++)
cout << d[j] << " ";
cout << endl;*/
}
}
int main()
{
speed();
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3056 ms |
5132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
356 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
151 ms |
5956 KB |
Output is correct |
2 |
Correct |
55 ms |
844 KB |
Output is correct |
3 |
Correct |
54 ms |
924 KB |
Output is correct |
4 |
Correct |
52 ms |
900 KB |
Output is correct |
5 |
Correct |
64 ms |
980 KB |
Output is correct |
6 |
Correct |
56 ms |
904 KB |
Output is correct |
7 |
Correct |
55 ms |
900 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Execution timed out |
3071 ms |
5140 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
214 ms |
5448 KB |
Output is correct |
2 |
Correct |
63 ms |
504 KB |
Output is correct |
3 |
Correct |
63 ms |
476 KB |
Output is correct |
4 |
Correct |
62 ms |
420 KB |
Output is correct |
5 |
Correct |
75 ms |
508 KB |
Output is correct |
6 |
Correct |
72 ms |
504 KB |
Output is correct |
7 |
Correct |
65 ms |
500 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Execution timed out |
3092 ms |
5056 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
151 ms |
5956 KB |
Output is correct |
2 |
Correct |
55 ms |
844 KB |
Output is correct |
3 |
Correct |
54 ms |
924 KB |
Output is correct |
4 |
Correct |
52 ms |
900 KB |
Output is correct |
5 |
Correct |
64 ms |
980 KB |
Output is correct |
6 |
Correct |
56 ms |
904 KB |
Output is correct |
7 |
Correct |
55 ms |
900 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Execution timed out |
3071 ms |
5140 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3056 ms |
5132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |