# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
385219 | SansPapyrus683 | Rabbit Carrot (LMIO19_triusis) | C++17 | 99 ms | 5348 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_inc_subseq(const vector<int>& seq) {
vector<int> min_endings;
for (int i : seq) {
int pos = std::upper_bound(min_endings.begin(), min_endings.end(), i) - min_endings.begin();
if (pos == min_endings.size()) {
min_endings.push_back(i);
} else {
min_endings[pos] = i;
}
}
return min_endings.size();
}
/**
* https://oj.uz/problem/view/LMIO19_triusis
* 5 400
* 300
* 700
* 200
* 1000
* 500 should output 1
*/
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++) {
if (i * jump_height >= poles[i - 1]) {
poss_unchanged.push_back(i * jump_height - poles[i - 1]);
}
}
cout << pole_num - longest_inc_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... |