/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Accepted 8ms 840.0 KiB
#3 Accepted 8ms 908.0 KiB
#4 Accepted 8ms 956.0 KiB
#5 Accepted 8ms 788.0 KiB
#6 Accepted 8ms 836.0 KiB
#7 Accepted 8ms 952.0 KiB
#8 Accepted 8ms 580.0 KiB
#9 Accepted 3ms 576.0 KiB
#10 Accepted 3ms 576.0 KiB
#11 Accepted 8ms 952.0 KiB
#12 Accepted 8ms 788.0 KiB
#13 Accepted 8ms 832.0 KiB
#14 Accepted 8ms 948.0 KiB
#15 Accepted 8ms 788.0 KiB
#16 Accepted 8ms 740.0 KiB
#17 Accepted 8ms 836.0 KiB

Code

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
using namespace std;

void solve(int cs) {
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      int j = i;
      for (; i < n; i++) {
        if (a[i] == 2) {
          break;
        } else if (a[i] == 3) {
          res = max(res, i - j + 1);
        }
      }
    }
  }
  cout << res << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  cin >> tc;
  for (int cs = 1; cs <= tc; cs++) {
    solve(cs);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1036 Perfect subarray
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-11 03:12:13
Judged At
2024-11-11 03:27:49
Judged By
Score
100
Total Time
8ms
Peak Memory
956.0 KiB