#include <bits/stdc++.h>
using namespace std;
map<long long, long long> pos;
long long sum, res[200005], i, n, k, a[200005], val[200005], b[20], j, d;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  for (i = 1; i <= n; i++) cin >> val[i];
  sort(a + 1, a + n + 1);
  for (i = 1; i <= n; i++) {
    d = pos[a[i]];
    res[d] = sum + val[d];
    if (!k) continue;
    for (j = 2; j <= k; j++)
      if (b[1] > b[j]) swap(b[1], b[j]);
    if (b[1] < val[d]) {
      sum += val[d] - b[1];
      b[1] = val[d];
    }
  }
  for (i = 1; i <= n; i++) cout << res[i] << " ";
}
