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;
typedef long long ll;
typedef long double ld;
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
int main(){
ios_base::sync_with_stdio(false), cin.tie(NULL);
// freopen("cowjog.in", "r", stdin);
// freopen("cowjog.out", "w", stdout);
int pole_num, jump_height;
cin >> pole_num >> jump_height;
vector<int> poles(pole_num);
for(int &i : poles) cin >> i;
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]);
}
}
vector<int> ans;
for(int &i : poss_unchanged){
int pos = upper_bound(ans.begin(), ans.end(), i) - ans.begin();
if(pos == ans.size()){
ans.push_back(i);
}else{
ans[pos] = i;
}
}
cout << pole_num - ans.size() << '\n';
return 0;
}
Compilation message (stderr)
triusis.cpp: In function 'int main()':
triusis.cpp:28:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | if(pos == ans.size()){
| ~~~~^~~~~~~~~~~~~
# | 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... |