# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472395 | AbhishekPathak | Rabbit Carrot (LMIO19_triusis) | C++17 | 107 ms | 5304 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
using std::cout;
using std::endl;
using std::vector;
int longest_nondec_subseq(const vector<int>& seq) {
vector<int> min_endings;
for (int i : seq) {
// note that we use upper_bound instead of lower_bound bc it just has to be nondecreasing
int pos = std::upper_bound(min_endings.begin(), min_endings.end(), i) - min_endings.begin();
// standard LIS protocol
if (pos == min_endings.size()) {
min_endings.push_back(i);
} else {
min_endings[pos] = i;
}
}
return min_endings.size();
}
int main() {
int pole_num;
int jump_height;
std::cin >> pole_num >> jump_height;
vector<int> poles(pole_num);
for (int p = 0; p < pole_num; p++) {
std::cin >> poles[p];
}
vector<int> poss_unchanged;
for (int i = 1; i <= pole_num; i++) {
// only add if it has any hope of being unchanged
if (i * jump_height >= poles[i - 1]) {
poss_unchanged.push_back(i * jump_height - poles[i - 1]);
}
}
cout << pole_num - longest_nondec_subseq(poss_unchanged) << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |