/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 328.0 KiB
#2 Accepted 13ms 1.32 MiB
#3 Accepted 13ms 1.074 MiB
#4 Accepted 12ms 1.312 MiB
#5 Accepted 14ms 1.324 MiB
#6 Accepted 13ms 1.32 MiB
#7 Accepted 14ms 1.32 MiB
#8 Accepted 13ms 588.0 KiB
#9 Wrong Answer 5ms 640.0 KiB
#10 Accepted 5ms 588.0 KiB
#11 Accepted 14ms 1.23 MiB
#12 Accepted 13ms 1.266 MiB
#13 Wrong Answer 13ms 1.078 MiB

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