Submission #972308

#TimeUsernameProblemLanguageResultExecution timeMemory
972308sofija6Global Warming (CEOI18_glo)C++14
100 / 100
47 ms6592 KiB
#include <bits/stdc++.h> #define ll long long #define MAXN 200010 using namespace std; ll t[MAXN],lis[MAXN]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n,x,ans=0; cin >> n >> x; for (ll i=1;i<=n;i++) cin >> t[i]; vector<ll> v; for (ll i=1;i<=n;i++) { auto it=lower_bound(v.begin(),v.end(),t[i]); if (it==v.end()) { v.push_back(t[i]); lis[i]=v.size(); } else { lis[i]=it-v.begin()+1; v[it-v.begin()]=t[i]; } } v.clear(); for (ll i=n;i>0;i--) { auto it=lower_bound(v.begin(),v.end(),-t[i]); ans=max(ans,lis[i]+(it-v.begin())); t[i]+=x; it=lower_bound(v.begin(),v.end(),-t[i]); if (it==v.end()) v.push_back(-t[i]); else v[it-v.begin()]=-t[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...