Submission #937304

#TimeUsernameProblemLanguageResultExecution timeMemory
937304upedRabbit Carrot (LMIO19_triusis)C++14
100 / 100
60 ms5928 KiB
#include <bits/stdc++.h> #define DEBUG(x) cout << #x << ": " << x << '\n'; using namespace std; using ll = long long; int main() { ll n, m; cin >> n >> m; vector<ll> v(n + 1); v[0] = 0; for (int i = 1; i <= n; ++i) { ll x; cin >> x; v[i] = i * m - x; } vector<ll> dp; dp.push_back(0); for (int i = 1; i <= n; ++i) { auto it = upper_bound(dp.begin(), dp.end(), v[i]); if (it == dp.end()) { dp.push_back(v[i]); } else { int pos = it - dp.begin(); if (pos == 0) continue; dp[pos] = v[i]; } } cout << n + 1 - dp.size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...