Submission #985210

# Submission time Handle Problem Language Result Execution time Memory
985210 2024-05-17T12:46:57 Z CrazyBotBoy Sequence (APIO23_sequence) C++17
0 / 100
2000 ms 25536 KB
#include "sequence.h"
#include <vector>
#include <unordered_map>

int sequence(int N, std::vector<int> A) {
  int max_median_count = 0;
  // Iterate through all subarrays
  for (int l = 0; l < N; ++l) {
    std::unordered_map<int, int> count;
    for (int r = l; r < N; ++r) {
      // Update count for the current element
      count[A[r]]++;
      int num = A[r];

      // Check if the current element can be a median (early termination)
      if (count[num] <= max_median_count) {
        continue;
      }

      int half_length = (r - l + 1) / 2;
      if (count[num] >= half_length && count[num] <= half_length + 1) {
        max_median_count = std::max(max_median_count, count[num]);
      }
    }
  }

  return max_median_count;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Execution timed out 2080 ms 4180 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2023 ms 25536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -