제출 #920087

#제출 시각아이디문제언어결과실행 시간메모리
920087Sir_Ahmed_ImranGlobal Warming (CEOI18_glo)C++17
48 / 100
728 ms262144 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define nl '\n' #define ff first #define ss second #define ll long long #define append push_back #define all(x) (x).begin(),(x).end() #define pii pair<int,int> #define N 200001 #define M 1000000001 int a[N]; int Q[N]; struct Node{ int val; Node *L,*R; }; Node* getnode(){ Node* temp=new Node; temp->val=0; temp->L=NULL; temp->R=NULL; return temp; } class ST{ public: Node* root=getnode(); void update(int i,int x,Node* v,int s=0,int e=M){ if(e-s==1){ v->val=x; return; } int mid=(s+e)/2; if(v->L==NULL) v->L=getnode(); if(v->R==NULL) v->R=getnode(); if(i<mid) update(i,x,v->L,s,mid); else update(i,x,v->R,mid,e); v->val=max(v->L->val,v->R->val); } int get(int l,int r,Node* v,int s=0,int e=M){ if(r<=s || e<=l || l>=r || !v->val) return 0; if(l<=s && e<=r) return v->val; int mid=(s+e)/2; if(v->L==NULL) v->L=getnode(); if(v->R==NULL) v->R=getnode(); return max(get(l,r,v->L,s,mid),get(l,r,v->R,mid,e)); } }; void solve(){ int n,m,o,p,q,r; cin>>n>>m; ST x,y; for(int i=o=1;i<=n;i++) cin>>a[i]; for(int i=n;i>0;i--){ Q[i]=y.get(a[i],a[i]+1,y.root); y.update(a[i],y.get(a[i]+1,M,y.root)+1,y.root); } for(int i=1;i<=n;i++){ p=x.get(0,a[i],x.root)+1; y.update(a[i],Q[i],y.root); x.update(a[i],p,x.root); o=max(o,p+y.get(max(a[i]-m+1,0),M,y.root)); } cout<<o; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }

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

glo.cpp: In function 'void solve()':
glo.cpp:51:17: warning: unused variable 'q' [-Wunused-variable]
   51 |     int n,m,o,p,q,r;
      |                 ^
glo.cpp:51:19: warning: unused variable 'r' [-Wunused-variable]
   51 |     int n,m,o,p,q,r;
      |                   ^
#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...