제출 #982226

#제출 시각아이디문제언어결과실행 시간메모리
982226vjudge1서열 (APIO23_sequence)C++17
11 / 100
2078 ms29752 KiB
#include "sequence.h" #include<bits/stdc++.h> using namespace std; priority_queue<int>pql; priority_queue<int,vector<int>,greater<>>pqu; multiset<int>st2; void balance(){ if(pql.size()<pqu.size()) pql.push(pqu.top()),pqu.pop(); if(pql.size()-pqu.size()>1) pqu.push(pql.top()),pql.pop(); } int sequence(int N, std::vector<int> A) { int ans=1; for(int i=0;i<N;i++){ st2.clear(); while(pql.size()) pql.pop(); while(pqu.size()) pqu.pop(); pql.push(A[i]); st2.insert(A[i]); for(int j=i+1;j<N;j++) { if(A[j]<=pql.top()) pql.push(A[j]); else pqu.push(A[j]); balance(); st2.insert(A[j]); int a=pql.top(); int b=(pql.size()==pqu.size()?pqu.top():a); ans=max(ans,(int)st2.count(a)); ans=max(ans,(int)st2.count(b)); } } 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...