#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;
if(x > i*j) {pcnt++; continue;}
x -= i*j;
while(deq.size() > 1 && x > deq.front()) {
deq.pop_front();
pcnt++;
}
if(x <= deq[0]) deq.push_front(x);
else pcnt++;
}
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... |