/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 476.0 KiB
#2 Accepted 14ms 1.316 MiB
#3 Accepted 14ms 1.316 MiB
#4 Accepted 13ms 1.363 MiB
#5 Accepted 13ms 1.316 MiB
#6 Accepted 14ms 1.562 MiB
#7 Accepted 14ms 1.312 MiB
#8 Accepted 12ms 648.0 KiB
#9 Accepted 5ms 544.0 KiB
#10 Accepted 5ms 652.0 KiB
#11 Accepted 13ms 1.09 MiB
#12 Accepted 12ms 1.07 MiB
#13 Accepted 12ms 1.324 MiB
#14 Accepted 12ms 1.309 MiB
#15 Accepted 14ms 1.938 MiB
#16 Accepted 14ms 1.938 MiB
#17 Accepted 14ms 1.941 MiB

Code

/*CODED BY mahmudulsakib2019
  DATE:-27/3/2024;TIME:-17:00 PM
  BANGALDESH , SYLHET*/
#include<bits/stdc++.h>  
using namespace std;
typedef unsigned long long  ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--) {
      ll a,b=INT_MAX,c,count;
      cin >> a;
      bool start=false;
      vector<ll>p(a);
      vector<ll>q,s;
      for(ll i=0;i<a;i++){
        cin >> p[i];
      }
      for(ll i=0;i<a;i++){
        if(p[i]==1){
          start = true;
          b=min(b,i);
        }
        else if(p[i]==2){
          b=INT_MAX;
          start = false;
        }
        else if(p[i]==3){
          if(start){
            c=i;
            count = (c-b)+1;
            q.push_back(count);
          }

        }
      }
    if (!q.empty()) {
        auto it = max_element(q.begin(), q.end());
        cout << *it << endl;
    }
    else{
      cout << 0 << endl;
    }
    }
    return 0;
}


Information

Submit By
Type
Submission
Problem
P1036 Perfect subarray
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-27 13:30:49
Judged At
2024-11-11 03:40:05
Judged By
Score
100
Total Time
14ms
Peak Memory
1.941 MiB