제출 #919785

#제출 시각아이디문제언어결과실행 시간메모리
919785JakobZorz서열 (APIO23_sequence)C++17
0 / 100
2041 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 get_min(int l,int r){ int res=1e9; for(int i=l;i<r;i++) res=min(res,tree[i]); return res; } int get_max(int l,int r){ int res=-1e9; for(int i=l;i<r;i++) res=max(res,tree[i]); return res; } 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=1; for(int v=0;v<n;v++){ for(int idx:arr[v]) for(int i=idx+1;i<=n;i++) tree[i]+=2; int l=0; for(int r=0;r<(int)arr[v].size();r++){ int min2=get_min(arr[v][r],n+1); int max2=get_max(arr[v][r],n+1); int min1=get_min(0,arr[v][l]+1); int max1=get_max(0,arr[v][l]+1); while(l<r&&(max1+(r-l+1)*4<min2||max2<min1)){ l++; min1=get_min(0,arr[v][l]+1); max1=get_max(0,arr[v][l]+1); } res=max(res,r-l+1); } } 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...