제출 #952560

#제출 시각아이디문제언어결과실행 시간메모리
952560SundavarGlobal Warming (CEOI18_glo)C++14
58 / 100
109 ms5460 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n,d; cin>>n>>d; vector<int> v(n); for(int& a : v) cin>>a; vector<int> smallest(n+1, 1e9+7), here(n); smallest[0] = 0; for(int i = 0; i < n; i++){ int l = lower_bound(smallest.begin(), smallest.end(), v[i]) - smallest.begin(); here[i] = l; smallest[l] = v[i]; } vector<int> biggest(n+1, -1e9+7); biggest[0] = 1e9+7; int sol = 0; for(int i = n-1; i >= 0; i--){ int l = 0, r = n; while(r-l > 1) if(biggest[(r+l)/2] > v[i]-d) l = (l+r)/2; else r = (l+r)/2; sol = max(sol, l+here[i]); l = 0, r = n; while(r-l > 1) if(biggest[(r+l)/2] > v[i]) l = (l+r)/2; else r = (l+r)/2; biggest[l+1] = v[i]; } cout << sol << "\n"; }
#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...