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 <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vp;
#define nl "\n"
#define fr first
#define sc second
#define pb push_back
#define all(x) x.begin(), x.end()
#define fur(i, a, b) for(ll i = a; i <= b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= b; --i)
#define pv(x) for(auto k : x){cout << k << " ";} cout << nl
ll n;
vl d;
void patch(ll l, ll r, ll s, ll c){
fur(i, l, r)
d[i] += s + (i - l)*c;
}
void rewrite(ll l, ll r, ll s, ll c){
fur(i, l, r)
d[i] = s + (i - l)*c;
}
ll lenpro(ll l, ll r){
if (l == r){
return 1;
}
ll mxl = 1;
ll k = d[l + 1] - d[l];
ll len = 1;
fur(i, l + 1, r){
if (d[i] - d[i - 1] == k){
len++;
mxl = max(len, mxl);
}else{
len = 2;
k = d[i] - d[i - 1];
}
}
return mxl;
}
void solve(){
ll t;
cin >> t;
if (t == 3){
// cout << "evaluate" << nl;
ll l, r;
cin >> l >> r;
// cout << "in [" << l << ", " << r << "] : " << lenpro(l, r) << nl;
cout << lenpro(l, r) << nl;
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
ll q;
cin >> n >> q;
d.resize(n + 1);
fur(i, 1, n)
cin >> d[i];
while(q--){
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... |