제출 #982263

#제출 시각아이디문제언어결과실행 시간메모리
982263vjudge1서열 (APIO23_sequence)C++17
28 / 100
2067 ms29692 KiB
#include "sequence.h" #include<bits/stdc++.h> using namespace std; priority_queue<int>pql; priority_queue<int,vector<int>,greater<>>pqu; map<int,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[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[A[j]]++; int a=pql.top(); int b=(pql.size()==pqu.size()?pqu.top():a); ans=max(ans,st2[a]); ans=max(ans,st2[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...