This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#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;
int n, q;
ll d[maxn], b[maxn];
void input()
{
cin >> n >> q;
for (int i = 1; i <= n; i ++)
{
cin >> d[i];
b[i] = d[i] - d[i - 1];
}
}
int query(int l, int r)
{
if (l == r)
return 1;
int cnt = 1, mx = 0;
for (int i = l + 2; i <= r; i ++)
{
if (b[i] == b[i -1])
cnt ++;
else
{
if (cnt > mx)
mx = cnt;
cnt = 1;
}
}
if (cnt > mx)
mx = cnt;
return mx + 1;
}
void simulate()
{
for (int i = 1; i <= q; i ++)
{
int type, l, r;
ll s, c;
cin >> type >> l >> r;
if (type == 3)
{
cout << query(l, r) << endl;
}
else if (type == 1)
{
cin >> s >> c;
for (int j = l; j <= r; j ++)
{
d[j] += s + (ll)(j - l) * c;
}
b[l] += s;
for (int j = l + 1; j <= r; j ++)
b[j] += c;
b[r + 1] = d[r + 1] - d[r - 1];
}
else
{
cin >> s >> c;
for (int j = l; j <= r; j ++)
{
d[j] = s + (ll)(j - l) * c;
}
for (int j = l + 1; j <= r; j ++)
b[j] = c;
b[l] = d[l] - d[l - 1];
b[r + 1] = d[r + 1] - d[r];
}
/**for (int j = 1; j <= n; j ++)
{
b[j] = d[j] - d[j - 1];
}*/
/**for (int j = 1; j <= n; j ++)
cout << d[j] << " ";
cout << endl;*/
}
}
void solve()
{
input();
simulate();
}
int main()
{
speed();
solve();
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... |