func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 300005;   int n, k, pos[N];   long long c[N], ans;   vector<int> v;   priority_queue<pair<long long, int> > q;   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %lld , &c[i]);     for (int i = 1; i <= n + k; i++) {       if (i <= n) q.push(make_pair(c[i], i));       if (k < i) {         int x = q.top().second;         long long w = q.top().first;         q.pop();         ans += w * ((long long)i - (long long)x);         v.push_back(x);       }     }     printf( %lld n , ans);     for (int i = 0; i < v.size(); i++) pos[v[i]] = i + k + 1;     for (int i = 1; i <= n; i++) printf( %d  , pos[i]);     return 0;   }   