제출 #919725

#제출 시각아이디문제언어결과실행 시간메모리
919725JakobZorz서열 (APIO23_sequence)C++17
0 / 100
2036 ms35408 KiB
#include"sequence.h" #include<vector> #include<iostream> using namespace std; int n; int arr2[500000]; int tree[500001]; 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; } for(int i=0;i<=n;i++) tree[i]=-i; int res=0; for(int v=0;v<n;v++){ for(int idx=0;idx<(int)arr[v].size();idx++){ for(int i=arr[v][idx]+1;i<=n;i++) tree[i]+=2; int min2=1e9; int max2=-1e9; for(int i=arr[v][idx];i<=n;i++){ int sum=tree[i]; min2=min(min2,sum); max2=max(max2,sum); } int min1=1e9; int max1=-1e9; for(int i=0;i<arr[v][idx];i++){ int sum=tree[i]; min1=min(min1,sum); max1=max(max1,sum); //cout<<min1<<" "<<max1<<", "<<min2<<" "<<max2<<"\n"; if(max1<min2-1||max2<min1) continue; int i2=0; while(arr[v][i2]<i) i2++; res=max(res,idx-i2+1); break; } /*for(int i=0;i<n;i++){ int num=0; for(int j=i;j<n;j++){ if(arr2[j]==v) num++; int sum=tree2[j+1]-tree2[i]; if(sum==0||sum==1) res=max(res,num); } }*/ } } return res; }
#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...