Submission #1184666

#TimeUsernameProblemLanguageResultExecution timeMemory
1184666petezaRabbit Carrot (LMIO19_triusis)C++20
0 / 100
1 ms328 KiB
#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;
        while(deq.size() > 1 && x > deq.front()) {
            deq.pop_front();
            pcnt++;
        }
        if(deq.size() != 1) deq.push_front(x);
        else if(x <= deq[0]) deq.push_front(x);
        else pcnt++;
    }
    cout << pcnt;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...