/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 2ms 324.0 KiB
#4 Accepted 2ms 324.0 KiB
#5 Accepted 2ms 532.0 KiB
#6 Accepted 2ms 536.0 KiB
#7 Accepted 1ms 324.0 KiB

Code


#include <vector>
#include <iostream>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    vector<int> d(3);
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      auto w = d;
      for (int j = 0; j < 3; j++) {
        if (j == 0 || w[j] > 0) {
          int t = (x + j) % 3;
          d[t] = max(d[t], w[j] + 1);
        }
      }
    }
    cout << d[0] << '\n';
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1013 Divisible by 3
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 21:49:48
Judged At
2024-11-11 03:31:24
Judged By
Score
100
Total Time
2ms
Peak Memory
536.0 KiB