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 <bits/stdc++.h>
using namespace std;
int main() {
// freopen("main.in", "r", stdin);
// freopen(".out", "w", stdout);
int n, h; cin >> n >> h;
vector<int> poles(n);
for (int i = 0; i < n; i++) cin >> poles[i];
vector<int> same;
for(int i = 1; i <= n; i++)
if(i * h >= poles[i-1]) same.push_back(i * h - poles[i - 1]);
vector<int> min_endings;
for (auto i : same){
int pos = upper_bound(min_endings.begin(), min_endings.end(), i) - min_endings.begin();
if(pos == int(min_endings.size())) min_endings.push_back(i);
else min_endings[pos] = i;
}
cout << n - int(min_endings.size()) << endl;
}
# | 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... |