Submission #471694

#TimeUsernameProblemLanguageResultExecution timeMemory
471694dqkRabbit Carrot (LMIO19_triusis)C++17
100 / 100
37 ms4164 KiB
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int n, m; std::cin >> n >> m; std::vector<int> a(n + 1, 0); for (int i = 1; i <= n; ++i) { std::cin >> a[i]; a[i] = m * i - a[i]; } std::vector<int> dp; for (int i = 0; i <= n; ++i) { if (a[i] >= 0) { auto it = std::lower_bound(dp.begin(), dp.end(), a[i] + 1); if (it == dp.end()) { dp.push_back(a[i]); } else { *it = a[i]; } } } std::cout << n + 1 - dp.size() << "\n"; 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...