func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 10;   class event {    public:     long long t;     int id, type;     event() {}     event(long long a, int b, int c) {       t = a;       id = b;       type = c;     }     bool operator<(const event& other) const {       if (t != other.t) return other.t < t;       if (type != other.type) return other.type < type;       return other.id < id;     }   };   int n, p;   long long A[MAXN];   priority_queue<event> pq;   set<int> hold, qu;   long long last;   int main() {     scanf( %d %d , &n, &p);     for (int i = 1; i <= n; i++) {       scanf( %lld , &A[i]);       pq.push(event(A[i], i, 2));     }     while (!pq.empty()) {       event top = pq.top();       pq.pop();       if (top.type == 2) {         if (qu.empty()) {           qu.insert(top.id);           pq.push(event(top.t + p, top.id, 1));           last = top.t + p;         } else if (*qu.begin() > top.id) {           qu.insert(top.id);           pq.push(event(last + p, top.id, 1));           last = last + p;         } else {           hold.insert(top.id);         }       } else {         A[top.id] = top.t;         qu.erase(top.id);         set<int>::iterator lb = hold.lower_bound(top.id);         if (lb != hold.end()) {           pq.push(event(top.t, *lb, 2));           hold.erase(lb);         }       }     }     for (int i = 1; i <= n; i++) printf( %lld  , A[i]);     printf(  n );     return 0;   }   