제출 #919599

#제출 시각아이디문제언어결과실행 시간메모리
919599JakobZorz서열 (APIO23_sequence)C++17
11 / 100
2041 ms38732 KiB
#include"sequence.h" #include<vector> using namespace std; int n; int tree1[500000]; int tree2[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); tree1[i]=-1; tree2[i]=-1; } int res=0; for(int v=0;v<n;v++){ if(arr[v].empty()) continue; for(int i:arr[v]) tree1[i]=1; for(int i=0;i<n;i++){ int sum1=0,sum2=0,num=0; for(int j=i;j<n;j++){ sum1+=tree1[j]; sum2+=tree2[j]; if(tree1[j]==1&&tree2[j]==-1) num++; if(sum1>=0&&sum2<=0) res=max(res,num); } } for(int i:arr[v]) tree2[i]=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...