Submission #1171860

#TimeUsernameProblemLanguageResultExecution timeMemory
1171860ov113Rabbit Carrot (LMIO19_triusis)C++20
100 / 100
51 ms3516 KiB
#include <algorithm> #include <iostream> #include <vector> using namespace std; int max_non_dec_subseq(const vector<int> &seq) { vector<int> dp; for (auto x : seq) { int pos = upper_bound(dp.begin(), dp.end(), x) - dp.begin(); if (pos == dp.size()) { dp.push_back(x); } else { dp[pos] = x; } } return dp.size(); } int main() { int n, m; cin >> n >> m; int a[n+1]; a[0] = 0; for (int i=1; i<=n; i++) { cin >> a[i]; a[i] -= i*m; } vector<int> poss_unchanged; for (int i=0; i<=n; i++) { if (a[i] <= 0) { poss_unchanged.push_back(-a[i]); } } cout << (n+1) - max_non_dec_subseq(poss_unchanged) << '\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...