Submission #985210

#TimeUsernameProblemLanguageResultExecution timeMemory
985210CrazyBotBoySequence (APIO23_sequence)C++17
0 / 100
2080 ms25536 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...