Submission #976261

#TimeUsernameProblemLanguageResultExecution timeMemory
976261josanneo22Sequence (APIO23_sequence)C++17
28 / 100
2067 ms31808 KiB
#include "sequence.h" #include <vector> #include <bits/stdc++.h> using namespace std; int sequence(int N, std::vector<int> a) { int ans = 0; for (int i = 0; i < N; i++) { priority_queue<int> front; priority_queue<int, vector<int>, greater<int>> back; map<int, int> cnt; for (int j = i; j < N; j++) { front.push(a[j]); cnt[a[j]]++; while (front.size() - back.size() >= 2) { back.push(front.top()); front.pop(); } while (back.size() && front.top() > back.top()) { int A = front.top(); front.pop(); int B = back.top(); back.pop(); back.push(A); front.push(B); } if (front.size() == back.size()) { int m1 = front.top(); int m2 = back.top(); ans = max(ans, cnt[m1]); ans = max(ans, cnt[m2]); } else { int m1 = front.top(); ans = max(ans, cnt[m1]); } } } return ans; } // #include "grader.cpp"
#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...