Submission #480667

#TimeUsernameProblemLanguageResultExecution timeMemory
480667ASIXERRabbit Carrot (LMIO19_triusis)C++17
100 / 100
38 ms3652 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const ll mod = (ll)1e9+7; void solve(){ int n,m; cin>>n>>m; vector<int> a(n); for(int i=0;i<n;i++){ cin>>a[i]; a[i]-=(i+1)*m; } reverse(a.begin(),a.end()); vector<int> lis; for(auto ai:a){ int pos=upper_bound(lis.begin(),lis.end(),ai)-lis.begin(); if(pos==(int)lis.size()) lis.push_back(ai); else lis[pos]=ai; } cout<<n-(upper_bound(lis.begin(),lis.end(),0)-lis.begin())<<"\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int T=1; //cin>>T; while(T--) solve(); 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...