Wrong Answer
Code
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int t; cin >> t;
while (t--) {
int n; cin >> n;
vector <int> a(n);
for (auto& x:a) cin >> x;
int ans (0), c(0);
bool f (true);
for (int i(0); i < n; i++) {
if (a[i] == 1) {
f = true; c++;
}
else if (a[i] != 2 && f) {
c++;
}
else if (a[i] == 2) {
f = false; c = 0;
}
if (a[i] == 3) {
ans = max (ans, c);
}
}
cout << ans << '\n';
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1036 Perfect subarray
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-03-26 09:48:27
- Judged At
- 2024-11-11 03:40:18
- Judged By
- Score
- 60
- Total Time
- 14ms
- Peak Memory
- 1.324 MiB