Submission #1181769

#TimeUsernameProblemLanguageResultExecution timeMemory
1181769adriannnProgression (NOI20_progression)C++20
0 / 100
3095 ms2636 KiB
#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;
        if (input == 3){
            cin >> L >> R;
            evaluate(stages, L, R);
        }
        else if (input == 1){
            cin >> a >> b >> c >> d;
        }
        else if (input == 2){
            cin >> a >> b >> c >> d;
        }
    }

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...