/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 2ms 332.0 KiB
#2 Wrong Answer 31ms 1.289 MiB

Code

/*CODED BY mahmudulsakib2019
  DATE:-12/03/2024;TIME:-16:10 pm
  BANGALDESH , SYLHET*/

#include <iostream>
#include <cmath>     ///mathematics
#include<cstdlib>    ///for std::exit(EXIT_SUCCESS)
#include <vector>    ///array
#include <regex>     ///searching_prefix_suffix
#include <algorithm> ///finding_max_min_from_array
#include <string>    ///string_manipulation
#include <numeric>   ///findin total sum of an array

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int T;
    cin >> T;
    while(T--) {
        long long int N;
        cin >> N;
        vector<long long int> arr(N);
        for(int i = 0; i < N; i++) {
            cin >> arr[i];
        }
        long long int maxLen = 0;
        long long int len = 0;
        for(int i = 0; i < N; i++) {
            if(arr[i] == 1) {
                len = 1;
            } else if(arr[i] == 2) {
                len = 0;
            } else if(arr[i] == 3 && len > 0) {
                len++;
                maxLen = max(maxLen, len);
            } else if(len > 0) {
                len++;
            }
        }
        cout << maxLen << endl;
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1036 Perfect subarray
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-12 18:27:37
Judged At
2024-11-11 03:40:54
Judged By
Score
0
Total Time
31ms
Peak Memory
1.289 MiB