이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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++) {
map<int,int> m;
multiset<int> low, high;
for (int j=i;j<N;j++) {
if (low.empty() || A[j]<=*low.rbegin()) {
low.insert(A[j]);
} else {
high.insert(A[j]);
}
while (low.size() > high.size() + 1) {
high.insert(*low.rbegin());
low.erase(prev(low.end()));
}
while (high.size() > low.size()) {
low.insert(*high.begin());
high.erase(high.begin());
}
m[A[j]]++;
int m1 = *low.rbegin();
int m2 = (low.size()+high.size())%2==0?*high.begin():m1;
int occ1 = m[m1], occ2=m[m2];
ans = max(ans,occ1);
if (m1!=m2) {
ans=max(ans,occ2);
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |