제출 #980958

#제출 시각아이디문제언어결과실행 시간메모리
980958nnin서열 (APIO23_sequence)C++17
28 / 100
2045 ms10248 KiB
#include "sequence.h" #include<bits/stdc++.h> using namespace std; int ct[500005]; priority_queue<int> le; priority_queue<int, vector<int>, greater<int>> ri; int sequence(int N, std::vector<int> A) { int ret = 0; for(int l=0;l<N;l++) { while(!le.empty()) ct[le.top()]--, le.pop(); while(!ri.empty()) ct[ri.top()]--, ri.pop(); for(int r=l;r<N;r++) { if(le.empty() || A[r]<=le.top()) le.push(A[r]); else ri.push(A[r]); if(le.size()>ri.size()+1) { ri.push(le.top()); le.pop(); } if(ri.size()>le.size()) { le.push(ri.top()); ri.pop(); } ct[A[r]]++; ret = max(ret, ct[le.top()]); if(le.size()==ri.size()) ret = max(ret, ct[ri.top()]); } } return ret; }
#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...