Submission #1216268

#TimeUsernameProblemLanguageResultExecution timeMemory
1216268amaninnightRabbit Carrot (LMIO19_triusis)C++20
14 / 100
1 ms328 KiB
#include<bits/stdc++.h> #define pb push_back #define all(x) x.begin(),x.end() #define $boost cin.tie(0) -> sync_with_stdio(0), cout.tie(0); #define F first #define S second using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef vector<int> VI; typedef vector<ll> VLL; const int maxn = 2e5 + 5, mod = 1e9 + 7; int a[maxn]; void solve(){ int n, m; cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i]; a[i] -= (i * m); } // for(int i = 0; i <= n; i++) cout << a[i] << " "; cout << endl; vector<int> v; v.pb(0); for(int i = 1; i <= n; i++){ if(a[i] <= v.back()){ v.pb(a[i]); } else{ int l = 0, r = v.size() - 1; while(r-l > 1){ int mid = (r+l)/2; if(v[mid] >= a[i]) l = mid; else r = mid; } l++; v[l] = a[i]; } } cout << n-v.size()+1 << endl; } int main(){ $boost; int t = 1; //cin >> t; while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...