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>
#include <ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
typedef tree < pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
bool cmp(pair<int, int>& a, pair<int, int>& b) { return a.second < b.second; }
#define ll long long
#define mod 1000000007
#define mod2 99824435
const int INF = (int)1e9;
int add(int i, int j) {
if ((i += j) >= mod)
i -= mod;
return i;
}
int sub(int i, int j) {
if ((i -= j) < 0)
i += mod;
return i;
}
const int MAXN = 201010;
const int N = 3e5+10;
vector<int>adj[N];
vector<int> st, en;
vector<vector<int>>up;
const int maxn = 1000;
int longest_nondec_subseq(const vector<int>& seq) {
vector<int> mine;
for (int i : seq) {
int pos = std::upper_bound(mine.begin(), mine.end(), i) - mine.begin();
if (pos == mine.size()) {
mine.push_back(i);
} else {
mine[pos] = i;
}
}
return mine.size();
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("herding.in","r",stdin);
//freopen("herding.out","w",stdout);
//set<int, greater<int>>st;
//
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;
for (int i = 1; i <= pole_num; i++) {
if (i * jump_height >= poles[i - 1]) {
poss.push_back(i * jump_height - poles[i - 1]);
}
}
cout << pole_num - longest_nondec_subseq(poss) << endl;
return 0;
}
Compilation message (stderr)
triusis.cpp: In function 'int longest_nondec_subseq(const std::vector<int>&)':
triusis.cpp:34:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | if (pos == mine.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... |