#include <iostream>
#include <vector>
#include <string>
using namespace std;
void evaluate(int A[], int l, int r){
if (r - l == 0){
cout << "1\n";
return;
}
if (r - l == 1){
cout << "2\n";
return;
}
int length, max;
length = 2;
max = 2;
for (int k = 1; k < r - l; k++){
if (A[k+l] - A[k+l-1] == A[k+l-1] - A[k+l-2]){
length++;
}
else{length = 2;}
if (max < length){
max = length;
}
}
cout << max << "\n";
}
int main(){
ios_base::sync_with_stdio(false);
int t, q, input, L, R, a, b, c, d;
cin >> t >> q;
int stages[t];
for (int i = 0; i < t; i++){
cin >> stages[i];
}
for (int j = 0; j < q; j++){
cin >> input;
cin >> L >> R;
evaluate(stages, L, R);
}
}
# | 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... |