제출 #868343

#제출 시각아이디문제언어결과실행 시간메모리
868343irmuun서열 (APIO23_sequence)C++17
28 / 100
2096 ms29704 KiB
#include<bits/stdc++.h> #include "sequence.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int sequence(int n,vector<int>A){ int ans=1; int cnt[n+1]; for(int i=0;i<n;i++){ fill(cnt,cnt+n+1,0); multiset<int,greater<int>>l; multiset<int>r; for(int j=i;j<n;j++){ cnt[A[j]]++; if(l.size()==r.size()){ if(l.size()==0||A[j]>=*r.begin()){ r.insert(A[j]); } else{ int x=*l.begin(); r.insert(x); l.erase(l.find(x)); l.insert(A[j]); } if(i!=j){ ans=max(ans,cnt[*r.begin()]); } } else{ if(A[j]<=*r.begin()){ l.insert(A[j]); } else{ int x=*r.begin(); l.insert(x); r.erase(r.find(x)); r.insert(A[j]); } ans=max({ans,cnt[*l.begin()],cnt[*r.begin()]}); } } } 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...