Submission #954264

#TimeUsernameProblemLanguageResultExecution timeMemory
954264Trisanu_DasSequence (APIO23_sequence)C++17
28 / 100
2083 ms32596 KiB
#include <bits/stdc++.h> #include "sequence.h" using namespace std; int sequence(int n, vector<int> a){ int occ[n + 1], ans = 0; for(int i = 0; i < n; i++){ memset(occ, 0, sizeof(occ)); multiset<int> l, r; for(int j = i; j < n; j++){ occ[a[j]]++; if(r.empty() || a[j] <= *r.begin()) l.insert(a[j]); else r.insert(a[j]); if(l.size() > r.size() + 1){ r.insert(*--l.end()); l.erase(--l.end()); } if(r.size() > l.size()){ l.insert(*r.begin()); r.erase(r.begin()); } ans = max(ans, occ[*--l.end()]); if(l.size() == r.size()) ans = max(ans, occ[*r.begin()]); } } return ans; }
#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...