Accepted
Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int arr[n];
for(int i=0; i<n; i++)
{
cin>>arr[i];
}
int one = 0;
int thr = 0;
int len= 0;
for(int i=1; i<n+1; i++)
{
if(arr[i-1]==1)
{
if(one>0)
{
one = min(one,i);
}
else
{
one = i;
}
}
else if(arr[i-1]==2)
{
one = 0;
continue;
}
else if(arr[i-1]==3)
{
if(one>0)
{
len = max(len,(i-one+1));
}
}
}
cout<<len<<endl;
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1036 Perfect subarray
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-03-12 11:55:41
- Judged At
- 2024-11-11 03:40:57
- Judged By
- Score
- 100
- Total Time
- 18ms
- Peak Memory
- 1020.0 KiB