Submission #556851

#TimeUsernameProblemLanguageResultExecution timeMemory
556851loctildoreGlobal Warming (CEOI18_glo)C++14
15 / 100
25 ms5468 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define f first #define s second #define endl '\n' #define all(x) begin(x), end(x) #define bitm 262144 int n,x,maximum; int val[200069]; int lis[200069]; int bit[262169]; vector<int> compress; unordered_map<int,int> um; void addl(int i, int y) { while (i<=bitm) { bit[i]=max(bit[i],y); i+=(i&-i); } } int findl(int i) { int rtn=0; while (i) { rtn=max(rtn,bit[i]); i-=(i&-i); } return rtn; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); for (int i = 1; i < 200069; i++) { lis[i]=INT_MAX; } cin>>n>>x; for (int i = 0; i < n; i++) { cin>>val[i]; compress.push_back(val[i]); } /*sort(all(compress)); for (int i = 0; i < n; i++) { um[compress[i]]=i+1; }*/ for (int i = 0; i < n; i++) { int tmp=lower_bound(lis,lis+200069,val[i]+x)-lis; tmp=max(tmp,findl(val[i]-1)+1); addl(val[i],tmp); maximum=max(maximum,tmp); tmp=lower_bound(lis,lis+200069,val[i])-lis; lis[tmp]=val[i]; maximum=max(maximum,tmp); } cout<<maximum<<endl; return 0; }
#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...