Submission #629957

#TimeUsernameProblemLanguageResultExecution timeMemory
629957NintsiChkhaidzeGlobal Warming (CEOI18_glo)C++14
100 / 100
136 ms5472 KiB
#include <bits/stdc++.h> #define ll long long #define s second #define pb push_back #define f first using namespace std; const int N = 200005; int a[N],l[N],r[N]; vector <int> vec; signed main() { int n,x; cin>>n>>x; for (int i = 1; i <= n; i++) vec.pb(1e9); for (int i = 1; i <= n; i++){ cin>>a[i]; int id = lower_bound(vec.begin(),vec.end(), a[i]) - vec.begin(); vec[id] = a[i]; l[i] = id + 1; } vec.clear(); for (int i = 1; i <= n; i++) vec.pb(1e9); for (int i = n; i >= 1; i--){ int val = -(a[i] - x); int id = lower_bound(vec.begin(),vec.end(), val) - vec.begin(); r[i] = id + 1; id = lower_bound(vec.begin(),vec.end(), -a[i]) - vec.begin(); vec[id] = -a[i]; } int ans=0; for (int i = 1; i <= n; i++) ans=max(ans,l[i] + r[i] - 1); cout<<ans<<"\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...