Submission #599172

# Submission time Handle Problem Language Result Execution time Memory
599172 2022-07-19T11:17:14 Z isaachew Global Warming (CEOI18_glo) C++17
10 / 100
109 ms 4064 KB
#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';
    }
    /*
    if(n*x<300000){
        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,1000000001));//minimum value with a LIS of (number) (or less?)
            for(int i=0;i<n;i++){
                int cur=vec[i];
                auto lb=std::lower_bound(rlis[0].begin(),rlis[0].end(),vec[cur]);
                
                auto lb2_1=std::lower_bound(rlis[0].begin(),rlis[0].end(),vec[cur]+l);
                auto lb2_2=std::lower_bound(rlis[1].begin(),rlis[1].end(),vec[cur]);
                
                auto lb3_1=std::lower_bound(rlis[1].begin(),rlis[1].end(),vec[cur]-l);
                auto lb3_2=std::lower_bound(rlis[2].begin(),rlis[2].end(),vec[cur]);
                
                vals[0][i]=(lb-rlis[0].begin())%n;
                rlis[0][vals[0][i]+1]=cur;
                vals[1][i]=std::max(lb2_1-rlis[0].begin(),lb2_2-rlis[1].begin())%n;
                rlis[1][vals[1][i]+1]=cur;
                vals[2][i]=std::max(lb3_1-rlis[1].begin(),lb3_2-rlis[2].begin())%n;
                rlis[2][vals[2][i]+1]=cur;
            }
            std::cout<<vals[2][n-1]<<'\n';
        }
    }
     */
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 99 ms 1940 KB Output is correct
2 Correct 106 ms 3872 KB Output is correct
3 Correct 88 ms 3900 KB Output is correct
4 Correct 109 ms 4064 KB Output is correct
5 Correct 59 ms 3156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -