Submission #863391

#TimeUsernameProblemLanguageResultExecution timeMemory
863391ArthasGlobal Warming (CEOI18_glo)C++17
100 / 100
53 ms3932 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(),x.end() const int N = 3e5 + 10, INF = 2e9 + 10; int n, x, a[N], l[N], ans; vector <int> v(N, INF); int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> x; for (int i = 0; i < n; ++ i){ cin >> a[i]; } v[0] = -INF; for (int i = 0; i < n; ++ i){ int p = lower_bound (all(v), a[i]) - v.begin(); v[p] = a[i]; l[i] = p; ans = max (ans, p); } for (int i = 0; i < n; ++ i){ v[i] = INF; } v[0] = -INF; for (int i = n - 1; i >= 0; -- i){ int p = lower_bound (all(v), -a[i] + x) - v.begin(); ans = max (ans, l[i] + p - 1); p = lower_bound (all(v), -a[i]) - v.begin(); v[p] = -a[i]; } cout << ans; 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...