제출 #480553

#제출 시각아이디문제언어결과실행 시간메모리
480553DeepessonRabbit Carrot (LMIO19_triusis)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> const int inf = 1e9+900; struct Node { Node* left,*right; int val; int l,r; }; Node* novonode(void){ Node* x = (Node*)calloc(sizeof(Node),1); return x; } int update(int t,int k,Node* v){ 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){ Node* k = novonode(); v->left=k; k->l=la; k->r=m; } if(!v->right){ Node* k = novonode(); v->right=k; k->l=m+1; k->r=ra; } int a = update(t,k,v->left); int b = update(t,k,v->right); v->val=std::max(v->left->val,v->right->val); 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){ Node* k = novonode(); v->left=k; k->l=la; k->r=m; } if(!v->right){ Node* k = novonode(); v->right=k; k->l=m+1; k->r=ra; } int a = query(l,r,v->left); int b = query(l,r,v->right); return std::max(a,b); } Node inicio; const int val = 1e8; int main() { inicio.l=0; inicio.r=+1e9+10000; int N,T; std::cin>>N>>T; int array[N];for(auto&x:array)std::cin>>x; update(0,val,&inicio); for(int i=0;i!=N;++i){ int x=array[i]; int melhor = query(std::max(0,x-T),inf,&inicio); update(x,melhor+1,&inicio); } std::cout<<(N-(query(0,inf,&inicio)-val))<<"\n"; }

컴파일 시 표준 에러 (stderr) 메시지

triusis.cpp: In function 'int update(int, int, Node*)':
triusis.cpp:32:9: warning: unused variable 'a' [-Wunused-variable]
   32 |     int a = update(t,k,v->left);
      |         ^
triusis.cpp:33:9: warning: unused variable 'b' [-Wunused-variable]
   33 |     int b = update(t,k,v->right);
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...