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<vector>
using namespace std;
int n;
int arr2[500000];
int tree1[500000];
vector<int>arr[500000];
int sequence(int N,vector<int>A){
n=N;
for(int i=0;i<n;i++){
arr[A[i]-1].push_back(i);
arr2[i]=A[i]-1;
tree1[i]=-1;
}
int res=0;
for(int v=0;v<n;v++){
for(int idx:arr[v]){
tree1[idx]=1;
for(int i=0;i<n;i++){
int sum=0,num=0;
for(int j=i;j<n;j++){
sum+=tree1[j];
if(arr2[j]==v)
num++;
if(0<=sum&&sum<=1)
res=max(res,num);
}
}
}
}
return res;
}
# | 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... |