제출 #823729

#제출 시각아이디문제언어결과실행 시간메모리
823729hmm789서열 (APIO23_sequence)C++17
28 / 100
2058 ms34884 KiB
#include "sequence.h" #include <bits/stdc++.h> using namespace std; int sequence(int N, std::vector<int> A) { #define int long long int cnt[N+1], ans = 0; for(int i = 0; i < N; i++) { memset(cnt, 0, sizeof(cnt)); multiset<int> l, r; for(int j = i; j < N; j++) { cnt[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()); } if(l.size() == r.size()) { ans = max(ans, cnt[*--l.end()]); ans = max(ans, cnt[*r.begin()]); } else { ans = max(ans, cnt[*--l.end()]); } } } return ans; #undef int }
#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...