제출 #599209

#제출 시각아이디문제언어결과실행 시간메모리
599209isaachewGlobal Warming (CEOI18_glo)C++17
10 / 100
126 ms3872 KiB
#include <bits/stdc++.h> /* A suffix as the interval is not optimal ST3: Calc LIS and range for every interval by getting longest LIS for ending LIS with std::map tracking ST4 (LIS): calculate the LIS normally with std::map; O(n log n) ST5: calculate LIS but 3 states based on whether in interval or not; O(nxlog n) ST6: arbitrary distance Change one number at a time; this will change Only two transition differences can be affected by the shift */ int n,x; int main(){ std::cin>>n>>x; std::vector<int> vec; for(int i=0;i<n;i++){ int t; std::cin>>t; vec.push_back(t); } if(x==0){ std::vector<int> swlis(n+1,1000000001); int lis=0; for(int i=0;i<n;i++){ int slis=std::lower_bound(swlis.begin(),swlis.end(),vec[i])-swlis.begin();//first slot not less than //std::cout<<slis<<'\n'; lis=std::max(lis,slis); swlis[slis]=vec[i]; } std::cout<<lis+1<<'\n'; return 0; } //* if(n*x<2000000){ int lis=0; for(int l=-x;l<=x;l++){ std::vector<std::vector<int>> vals(3,std::vector<int>(n,0)); std::vector<std::vector<int>> rlis(3,std::vector<int>(n+1,2000000000));//minimum value with a LIS of (number) (or less?) for(int i=0;i<n;i++){ int cur=vec[i]; int lb=std::lower_bound(rlis[0].begin(),rlis[0].end(),cur)-rlis[0].begin(); int lb2_1=std::lower_bound(rlis[0].begin(),rlis[0].end(),cur+l)-rlis[0].begin(); int lb2_2=std::lower_bound(rlis[1].begin(),rlis[1].end(),cur)-rlis[1].begin(); int lb3_1=std::lower_bound(rlis[1].begin(),rlis[1].end(),cur-l)-rlis[1].begin(); int lb3_2=std::lower_bound(rlis[2].begin(),rlis[2].end(),cur)-rlis[2].begin(); vals[0][i]=lb; rlis[0][vals[0][i]]=cur; vals[1][i]=std::max(lb2_1,lb2_2); rlis[1][vals[1][i]]=cur; vals[2][i]=std::max(lb3_1,lb3_2); rlis[2][vals[2][i]]=cur; lis=std::max(lis,vals[0][i]); lis=std::max(lis,vals[1][i]); lis=std::max(lis,vals[2][i]); } } std::cout<<lis+1<<'\n'; } //*/ }
#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...