제출 #136221

#제출 시각아이디문제언어결과실행 시간메모리
136221SOIVIEONEGlobal Warming (CEOI18_glo)C++14
17 / 100
179 ms8256 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 222222; ll a[N], l[N], sz[N], la[N], d[N]; int main() { ll n, x; cin >> n >> x; for(int i = 1; i <= n; i ++) cin >> a[i]; int lis = 0; for(int i = 1; i <= n; i ++) { int id = lower_bound(l, l + lis, a[i]) - l; l[id] = a[i]; if(id == lis) lis ++; sz[i] = lis; la[i] = l[lis-1]; } int lds = 0, ans = 0; for(int i = n; i >= 1; i --) { int id = lower_bound(d, d + lds, -a[i]) - d; d[id] = -a[i]; if(id == lds) lds ++; if(a[i] + x > la[i - 1]) { ans = max(ans, (int)(sz[i - 1] + lds)); } } cout << ans; }
#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...