Submission #493778

# Submission time Handle Problem Language Result Execution time Memory
493778 2021-12-13T00:27:53 Z Deepesson Global Warming (CEOI18_glo) C++17
10 / 100
725 ms 179920 KB
#include <bits/stdc++.h>
const int inf = 1e9+900;
struct Node {
    int left,right;
    int val;
    int l,r;
    void inicializa(){
        l=0;
        r=+1e9+10000;
    }
};
Node mem[12000000];
int cursor= 2;
int novonode(void){
    if(cursor==12000000){
        assert(0);
    }
    return cursor++;
}
int update(int t,int k,Node* v){
    if(v==&mem[0])return 0;
    int la=v->l,ra=v->r;
    if(t<la||ra<t)return 0;
    if(la==ra){
        v->val=std::max(v->val,k);
        return k;
    }
    int m = (la+ra)/2;
    if(!v->left&&(t<la&&m<t)){
        int k = novonode();
        v->left=k;
        mem[k].l=la;
        mem[k].r=m;
    }
    if(!v->right&&(t<m+1&&ra<t)){
        int k = novonode();
        v->right=k;
        mem[k].l=m+1;
        mem[k].r=ra;
    }
    int a = update(t,k,&mem[v->left]);
    int b = update(t,k,&mem[v->right]);
    v->val=std::max(a,b);
    return v->val;
}
int query(int l,int r,Node* v){
    int la=v->l,ra=v->r;
    if(r<la||ra<l)return 0;
    if(la>=l&&ra<=r){
        return v->val;
    }
    int m = (la+ra)/2;
    if(!v->left){
        int k = novonode();
        v->left=k;
        mem[k].l=la;
        mem[k].r=m;
    }
    if(!v->right){
        int k = novonode();
        v->right=k;
        mem[k].l=m+1;
        mem[k].r=ra;
    }
    int a = query(l,r,&mem[v->left]);
    int b = query(l,r,&mem[v->right]);
    return std::max(a,b);
}
const int val = 1e8;
Node sega,segb;
int main()
{
    int N,T;
    std::cin>>N>>T;
    int array[N];for(auto&x:array)std::cin>>x;
    int resp=0;
    ///Caso d=0
    {
        std::vector<int> vec;
        for(int i=0;i!=N;++i){
            int x=array[i];
            auto it = std::lower_bound(vec.begin(),vec.end(),x);
            if(it==vec.end()){
                vec.push_back(x);
            }else *it=x;
        }
        resp=vec.size();
    }
    ///Caso d=T
    {
        sega.inicializa();
        segb.inicializa();
        for(int i=0;i!=N;++i){
            int base = array[i];
            int verdade = base - 1;
            ///Atualiza caso ele tenha adicionado
            {
                int futuro = verdade+T;
                int val1 = query(0,verdade,&segb);
                int val2 = query(0,futuro,&sega);
                update(base,std::max(val1,val2)+1,&segb);
            }
            ///Atualiza caso nao tenha adicionado
            update(base,query(0,verdade,&sega)+1,&sega);
        }
        resp=std::max(resp,std::max(query(0,inf,&sega),query(0,inf,&segb)));
    }
    std::cout<<(resp)<<"\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 725 ms 179560 KB Output is correct
2 Correct 674 ms 179920 KB Output is correct
3 Correct 680 ms 179640 KB Output is correct
4 Correct 694 ms 179792 KB Output is correct
5 Correct 443 ms 98288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 166 ms 57824 KB Output is correct
2 Correct 212 ms 57884 KB Output is correct
3 Correct 186 ms 57820 KB Output is correct
4 Incorrect 109 ms 31212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 326 ms 97820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -