#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k;
  cin >> n >> k;
  vector<long long> A(n), B(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++) cin >> B[i];
  vector<tuple<long long, long long, long long>> C(n);
  for (int i = 0; i < n; i++) C[i] = {A[i], B[i], i};
  sort(C.begin(), C.end());
  vector<long long> ans(n);
  multiset<long long> set;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if (set.size() > k) {
      sum -= *set.begin();
      set.erase(set.begin());
    }
    ans[get<2>(C[i])] = sum + get<1>(C[i]);
    set.insert(get<1>(C[i]));
    sum += get<1>(C[i]);
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
