| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 982290 | vjudge1 | Sequence (APIO23_sequence) | C++17 | 78 ms | 11288 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
int sequence(int N, std::vector<int> A) {
vector<int>V=A,ones,threes;
int ans=0,prev,cnt;
sort(V.begin(),V.end());
int med=2;
if(V[N/2]-2) med=V[N/2];
else med=V[N-1>>1];
if(med-2)
return count(V.begin(),V.end(),med);
ans=count(V.begin(),V.end(),med);
if(ans*2>=N)
return ans;
for(int i=0;i<N;i++)
if(A[i]<2)
ones.push_back(i);
else if(A[i]-2)
threes.push_back(i);
map<int,int>mp;
mp[0]=0;
prev=ones[0],cnt=1;
for(int i=1;i<ones.size();i++){
cnt+=2-ones[i]+prev;
if(mp.begin()->first>cnt) mp[cnt]=i; else
ans=max(ans,1+i-(--mp.upper_bound(cnt))->second);
prev=ones[i];
}
mp.clear();
mp[0]=0;
prev=threes[0],cnt=1;
for(int i=1;i<size(threes);i++){
cnt+=2-threes[i]+prev;
if(mp.begin()->first>cnt) mp[cnt]=i; else
ans=max(ans,1+i-(--mp.upper_bound(cnt))->second);
prev=threes[i];
}
mp.clear();
return ans;
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
