Wrong Answer
Code
#include <iostream>
#include <vector>
using namespace std;
int main() {
int T;
cin >> T;
while(T--) {
int N;
cin >> N;
vector<int> arr(N);
for(int i = 0; i < N; i++) {
cin >> arr[i];
}
int maxLen = 0;
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 17:48:30
- Judged At
- 2024-11-11 03:40:55
- Judged By
- Score
- 0
- Total Time
- 18ms
- Peak Memory
- 1020.0 KiB