Submission #769698

#TimeUsernameProblemLanguageResultExecution timeMemory
769698PlurmSequence (APIO23_sequence)C++17
28 / 100
2080 ms29744 KiB
#include "sequence.h" #include <bits/stdc++.h> using namespace std; int sequence(int N, std::vector<int> A) { int mx = 0; for (int i = 0; i < N; i++) { map<int, int> cnt; priority_queue<int> pql; priority_queue<int, vector<int>, greater<int>> pqh; for (int j = i; j < N; j++) { int cur; cnt[A[j]]++; pqh.push(A[j]); if (pqh.size() > pql.size()) { int x = pqh.top(); pqh.pop(); pql.push(x); } while (!pqh.empty() && pql.top() > pqh.top()) { int x = pql.top(); pql.pop(); int y = pqh.top(); pqh.pop(); pql.push(y); pqh.push(x); } if (pql.size() == pqh.size() && pql.top() != pqh.top()) cur = max(cnt[pql.top()], cnt[pqh.top()]); else cur = cnt[pql.top()]; mx = max(mx, cur); } } return mx; }
#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...