#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";
}
void patch(int A[], int l, int r, int s, int c){
for (int i = 0; i <= r - l; i++){
A[l+i-1] += s + (i) * c;
}
}
void rewrite(int A[], int l, int r, int s, int c){
for (int i = 0; i <= r - l; i++){
A[l+i-1] = s + (i) * c;
}
}
int main(){
ios_base::sync_with_stdio(false);
int t, q, input, L, R, S, C;
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;
if (input == 3){
cin >> L >> R;
evaluate(stages, L, R);
}
else if (input == 1){
cin >> L >> R >> S >> C;
patch(stages, L, R, S, C);
/*for (int i = 0; i < t; i++){
cout << stages[i] << " ";
}
cout << "\n";*/
}
else if (input == 2){
cin >> L >> R >> S >> C;
rewrite(stages, L, R, S, C);
/*for (int i = 0; i < t; i++){
cout << stages[i] << " ";
}
cout << "\n";*/
}
}
}
# | 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... |