#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int pcnt = 0;
ll n, j, x;
int main() {
cin.tie(0) -> sync_with_stdio(0);
cin >> n >> j;
deque<ll> deq(1, 0);
for(int i=1;i<=n;i++) {
cin >> x;
x -= i*j;
auto it = lower_bound(deq.begin(), deq.end(), x);
if(it == deq.begin()) deq.push_front(x);
else if(it == deq.end()) pcnt++;
else {
pcnt++;
it--;
*it = max(*it, x);
}
}
cout << pcnt;
}
# | 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... |